August 5, 2009 at 7:32 am
After you create a query and execute it, how do you save it? Everytime I try to save it, it opens up some folder called Projects; but I want to save the query on the database, not in some folder on my hard drive. Thx.
August 5, 2009 at 7:46 am
Hi, you need to create a stored procedure, see http://msdn.microsoft.com/en-us/library/aa258259(SQL.80).aspx
August 5, 2009 at 7:50 am
You have to give the query a name and then create it as a view. For example suppose I have the fallowing query:
SELECT Name, ProductNumber, ListPrice AS Price
FROM Production.Product
I can save this query with create view statement:
Create view ProductAndPrice
As
SELECT Name, ProductNumber, ListPrice AS Price
FROM Production.Product
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
August 5, 2009 at 8:34 am
What are you trying to do with the query? That might help us recommend a view or a stored procedure.
August 6, 2009 at 6:27 am
It does depend on what you're trying to do. You can save a query as a view, a procedure, a function... If it's just a pre-defined select statement, you probably want a view, but it's hard to know unless you tell us.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply