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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How i can Wait for user input in a script

Status
Not open for further replies.

isonlyme

Programmer
Apr 20, 2002
171
0
0
PR
hi,

Im trying to do a simple thing, waiting for a user to input
a value so i can pass it to a sql statement and do a select according to their input like:


Declare @USERINPUT varchar(50)
Select * from MYTABLE where MYFIELD = @USERINPUT

But the trick is I can't use it on a store procedure, just run it on SQL Analyzer.

Can this be done?, It can be done on ORACLE. Can it be done in SQL server 2k?

Thanks in advanced
 
Oracle has a built-in user interface called Oracle Forms.

SQL Server does not. You have to create a user interface with .NET, Access, or some other application, client- or Web-based, that can communicate with SQL Server and apply business rules and user event handling.

Under NO circumstances should you give Query Analyzer to Joe or Mary User. Uh-uh.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Pity the insomniac dyslexic agnostic. He stays up all night, wondering if there really is a dog.
 
You really shouldn't let your users have access to Query Analyzer.

Normally, people write an interface to SQL Server. This interface can be written in many different languages (VB, C#, ASP, PHP, etc...).

The front end app would prompt the user for a value, and then you use that value in your call to the database.

Does this make sense?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
[small]Yeah. What he said[/small] [bigsmile]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
thanks guy,

The script is for me to run not the user, I dont want to hard code a lot of parameters every time i ran it thats why i wanted a prompt on the analyzer for me to use

so first run i input "jjj"
next run i input "aaaa" and so on.

is there a way without using SP, or aditional external language?

thanks
 
I would suggest...

Code:
Declare @USERINPUT varchar(50)
[!]Set @USERINPUT = 'Blah'[/!]

Select * from MYTABLE where MYFIELD = @USERINPUT

Then, save this file somewhere (where you will be able to find it). Then, When you want to 're-run' it with different values, just load the file, change the input values, and run it.

I realize that typing the value every time (in Query Analyzer) may not be as pretty as a user interface box, but it is just as effective.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
thats what i was trying to avoid... thas why i wanted the prompt so for each loop it will ask me for the new value

nontheless thank you very much for your comments

 
>> for each loop

Do you mean to say... You wrote a loop in a query and you want each iteration through the loop to prompt you, so that you can type in a value? Are you serious?

Wow. Just wow.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
You are aware that loops are a very very bad thing in SQL server? It is usually best to do your work using set-based commands. It is very rare that a task cannot be done in a set-based fashion. Cursors and loops are performance killers (much more so than in Oracle from what I've read).



"NOTHING is more important in a database than integrity." ESquared
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top