|
Posted by Kimmo Laine on 08/25/05 10:41
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
Navigation:
[Reply to this message]
|