How to save a query in SQL Server so it is visible in Object Explorer
11,782
You cannot save Query
on SQL Server
. It's better to create a View
if you're planning to use it later
Related videos on Youtube
Author by
Liquidmetal
Updated on September 15, 2022Comments
-
Liquidmetal almost 2 years
I am SQL Server newbie, many of my thnkings are based on Access DB work.
I have searched for an answer to this question but have not found anything that answers it.
I have opened my query builder and when I close it - it asks to 'save as' and takes me to a folder. I save it but the query is not visible in object explorer, so how do I have access to it and how can I use it for making forms with InfoPath etc.
I have been searching all day and yet no results so I would be grateful for an explaination on how this can be done. Many thanks.
-
JayC over 11 yearsOf course, views can't have a default ordering, IIRC, so his query might not work there.
-
Andrey Gordeev over 11 yearsWell, OP is from
MS Access
, I think he meant a simpleSELECT
query -
JayC over 11 yearsI was refering to
ORDER BY
, sorry I wasn't being clearer. msdn.microsoft.com/en-us/library/ms187956.aspx => TheSELECT
clauses in a view definition cannot include the following: AnORDER BY
clause, unless there is also aTOP
clause in the select list of theSELECT
statement ... <= often simple select queries do have anORDER BY
clause.. of course the OP could use a SQL Function, which (also IIRC) doesn't have this restriction. -
Martin Smith over 11 years@JayC - A
SELECT ... FROM dbo.Function()
isn't guaranteed to return the result in any particular order either without anORDER BY
-
Liquidmetal over 11 yearsMany thanks for all your replies. Your replies show that I can create new views which will act as simple select queries but with user inout filters. I need the queries to be filters so by selecting from a drop down menu, a user can limit the data to the selected data. Also can someone point me in the right direction on how I can make forms for users to see the data, InfoPath is too dense for me at the moment and need something less weighty if possible?
-
Andrey Gordeev over 11 years@user2083178 That's a subject for another question.