March 23, 2006 at 2:22 pm
Is it possible to display a prompt a user for input (set variable) so I can write one sql to do many different things..
For example: Enter Month (01-12): 12 (12 is user input)
Then how would I reference that input to do a comparison in my where statement as follows:
datepart(dd,hire_date) = value entered in prompt statement
March 23, 2006 at 3:17 pm
not directly from TSQL, no; you'd have to write a program that would prompt for input, and then use the input in the sql to be performed;
Oracle (or rather, SQL PLUS) will do that when it encounters the & symbol unless you had SET DEFINE OFF; command.
Lowell
March 23, 2006 at 4:06 pm
How do I reference a static variable in a where statement in T-SQL. No user input, variable always = 12
then how would my datepart(dd,hire_date) command by set up?
thanks
March 23, 2006 at 5:32 pm
Actually, you can... well, sort of... make a call to xp_CmdShell and run a VB Script to ask the question and then pass it to a stored procedure.
It's a lot easier to do this in a batch file.
--Jeff Moden
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy