Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy Syntax Question - Prompts in queries

Status
Not open for further replies.
Nov 8, 2000
12
GB
Can someone let me know how to put prompts in a SQL Server query

In Oracle the code would be

Select x from table y
where field = '&&1';

this would then prompt the user for a &&1 value

I'd like to know the equivalent in SQL Server

Thanks for any help

 
You can't do this in T-SQL; you'd have to do it through some client tool.

For example, in Visual FoxPro the following would prompt for the value of LName:

[tt]sqlexec(sqlconnect(), ;
"select * from people where LastName = ?LName")[/tt]


Robert Bradley

 
Robert - thanks - what exactly is T-SQL ? - does that mean I can't do it in Query Analyser ?
 
Dear ;
You can make Stored Procedure which will take user input.

such as :

******************************************

CREATE PROCEDURE stp_Sample @P_ID int

AS

SELECT X from Y where Field = @P_ID

******************************************

it will ask for user input .

regards ,

essa2000


 
T-SQL is Transact SQL, the programming and query language of SQL Server.

Essa2000, your routine will indeed accept input, but it won't pop up a dialog box and prompt the user for the parameter. Running it without explicitly passing a parameter will get you the error Procedure 'sp_temp' expects parameter '@P_ID', which was not supplied.

Robert Bradley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top