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
 select query-STORED PROCEDURE

Author  Topic 

jonekim
Starting Member

35 Posts

Posted - 2011-05-27 : 00:07:20
I've created a database table;
**********************
user_registration #with fields
user_id,
user_roll, #roll are= 'M','W','C','S'
user_name,
user_address,
user_dateOfRegistration
************************
Now I want to write stored procedure to get all the information of a particular user roll according to the date of registration.
I mean if I supply @user_roll='M' & user_dateOfRegistration=@user_dateOfRegistration I get name, id & address of the user.
How can I write the stored procedure for this problem???

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-05-27 : 01:56:26
[code]
CREATE PROCEDURE usp_Getuser_registration
@user_roll varchar(10) ,
@user_dateOfRegistration DATE
AS
SELECT user_id,user_name,user_address
FROM user_registration
WHERE user_roll = @user_roll
and user_dateOfRegistration = @user_dateOfRegistration
[/code]

Use it like this:
EXECUTE usp_Getuser_registration @user_roll='M' , @user_dateOfRegistration='20110227'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

jonekim
Starting Member

35 Posts

Posted - 2011-05-27 : 16:03:57
@webfred thanks for the reply.
I dont want to enter @user_roll='M'. I simply want to enter the date of registration and get the list of patient registered on that particular date. How can I do that???
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2011-05-28 : 02:47:35
[code]

CREATE PROCEDURE usp_Getuser_registration
@user_dateOfRegistration DATE
AS
SELECT user_id,user_name,user_address
FROM user_registration
WHERE user_dateOfRegistration = @user_dateOfRegistration


Use it like this:
EXECUTE usp_Getuser_registration @user_dateOfRegistration='20110227'
[/code]
Go to Top of Page
   

- Advertisement -