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!

Creating an input prompt in SQL Server

Status
Not open for further replies.

sivi

IS-IT--Management
Nov 27, 2002
27
GB
I would be grateful for any help in the following:

I need to read a date input from the user in SQL. This date will be used as a parameter in an SQL query.

Please someone could advice me on this.

If this is possible how this could be done.

Many Thanks

Sivi
 
Usually we use getdate() to catch the system time.But I am not really sure what do you really mean?

here is an example
insert into table_name select 1,'John',getdate()
 
Claire

Thanks for your reply.

My requirement is to read a date from the user which will be inputted on the screen.

I normally do this in VB and send the inputted value as a parameter to a stored procedure in SQL.

But I want to read from the user on the screen from within SQL.

Thanks
Sivi
 
SQL Server is not a client interface. It's not its duty to create a nice prompt with blinking color and basic check.

What is your client (access, vb, asp...)?

Also search "raiseerror" to check the validity of the parameters and return an error
 
In SQL Server, you would create a stored procedure that accepts one or more variables and then the user would execute that stored procedure.

For example:

create procedure udp_myprocedure
as
declare @mydate datetime
select *
from mytable
where mydatefield > @mydate

that creates the stored procedure and this would run it:

exec udp_myprocedure '2003-06-10 12:00:00'

Check the Books OnLine for more information on stored procedures, create procedure, and variables.

-SQLBill
 
pascalsql, SQLBill

Many thanks for your comments.

Our interface is vb, but SQLBill's suggestion will help the situation.


Sivi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top