Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 choosing parameter in query

Author  Topic 

dirtyfishtank
Starting Member

8 Posts

Posted - 2011-12-22 : 05:15:52
Hi all, I am very new to SQL and I have a simple question for queries.

I am writing a query similar to the one below, which executes fine, however, I would like it to give me the option as to which parameters to include when it's being executed. I have seen it done before but not too sure how.

ie; when you hit execute, you get a tick box pop up allowing to choose which parameters appear in the table . I think it has something to do with '@parameter' but I don't know the syntax.

Can anyone please help?



SELECT TOP 100 [id]
,[status]
,[locationid]
,[operator]
,(startdate + '5:00:00') AS _startDate
,(enddate + '5:00:00') AS _endDate
,[duration]

FROM [books].[dbo].[telephones]
WHERE startdate > 2011-10-10
SORT BY _startDate asc

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-22 : 05:44:59
in standard sql editor which is sql server management studio you wont get any such pop ups. I think you're talking about doing it inside some other editor inside some application.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

dirtyfishtank
Starting Member

8 Posts

Posted - 2011-12-22 : 05:57:08
I've seen it done in SQL Server Manager, in a stored procedure rather than a table. Can that be done?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-22 : 06:09:25
quote:
Originally posted by dirtyfishtank

I've seen it done in SQL Server Manager, in a stored procedure rather than a table. Can that be done?


you mean enterprise manager in sql 2000?

in sql management studio, you need to create a procedure containing above code for that with parameter. then in management studio select the procedure, right click and select execute to get popup
see

http://www.mssqltips.com/sqlservertip/1375/dynamic-sql-server-stored-procedure-execution-form-in-ssms/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

dirtyfishtank
Starting Member

8 Posts

Posted - 2011-12-22 : 23:54:44
Thanks; that's exactly what I was trying to achieve
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-23 : 01:13:25
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -