Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

creating views

1 view
Skip to first unread message

Kimmo Laine

unread,
Aug 25, 2005, 3:41:59 AM8/25/05
to
I've got to do quite complex queries, and I've come to the point where I see
no other possibilities, than doing them with views. I'm using MS SQL Server
on IIS 6 on Win2003 server. I can make static views in my sql server
enterprise manager, but I'd like to be able to change them dynamically.
Right now I can get a view from the entire time, but it would be great if I
could insert parameters in the view, to get rows only where date > start
date and date < end date. So I'm thinking I could use CREATE VIEW and DROP
VIEW to be able to dynamically change the views. So I'm thinking something
like

mssql_query("CREATE VIEW dbo.my_view
AS
SELECT *
FROM something
WHERE date > $sdate and date < $edate";

// then I run my query
mssql_query("SELECT SUM(x) FROM my_view");

//Then I drop the view
mssql_query("DROP VIEW dbo.my_view");

The queries I'm doing are actually more complex than in my example, but
that's not the important thing. I'm convinced I gotta use views, and I'm
asking that is this a good way to dynamically create and drop views for the
purpouse. Does it work like that?

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com


Kimmo Laine

unread,
Aug 25, 2005, 4:36:10 AM8/25/05
to
"Kimmo Laine" <eternal.er...@Mgmail.com> wrote in message
news:QMePe.12498$cS7....@reader1.news.jippii.net...

> I've got to do quite complex queries, and I've come to the point where I
> see no other possibilities, than doing them with views. I'm using MS SQL
> Server on IIS 6 on Win2003 server. I can make static views in my sql
> server enterprise manager, but I'd like to be able to change them
> dynamically. Right now I can get a view from the entire time, but it would
> be great if I could insert parameters in the view, to get rows only where
> date > start date and date < end date. So I'm thinking I could use CREATE
> VIEW and DROP VIEW to be able to dynamically change the views. So I'm
> thinking something like

Answering to mysqlf: at least it seems to work as intended. Now the question
remains: is there a better way to accomplish it?

Berislav Lopac

unread,
Aug 25, 2005, 6:15:59 AM8/25/05
to
Kimmo Laine wrote:
> Answering to mysqlf

Now here's an appropriate typo... :)

Berislav


Kimmo Laine

unread,
Aug 25, 2005, 6:56:56 AM8/25/05
to
"Berislav Lopac" <berisla...@lopsica.com> wrote in message
news:dek5og$e3m$1...@garrison.globalnet.hr...

> Kimmo Laine wrote:
>> Answering to mysqlf
>
> Now here's an appropriate typo... :)
>


Oh my.. That must've been a Freudian penis, I mean slip... :)

0 new messages