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.
| Author |
Topic |
|
sparrow37
Posting Yak Master
148 Posts |
Posted - 2009-07-27 : 07:21:12
|
| Hi all,I have a table named 'users' with emailaddress, activation key,userid etc. I want that if user enters his emailaddress, I pass this email address to a stored procedure and check if emailaddress exists and isenable = 0( a bit field to check if user has already set enabled field = 1) then return all user info, else return 0. how to do this in stored procedure.Regards,Asif Hameed |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-07-27 : 07:44:05
|
| CREATE PROC Sp_USER @EMAILID VARCHAR(50)ASBEGIN IF EXISTS(SELECT 'X' FROM TABLE_NAME WHERE EMAILID = @EMAILID AND ISENABLE = 0) BEGIN SELECT * FROM USER_TABLE END ELSE BEGIN SELECT '0' ENDEND-------------------------R.. |
 |
|
|
sparrow37
Posting Yak Master
148 Posts |
Posted - 2009-07-27 : 07:50:01
|
| how to fetch different types from one sp means a table and an integer value ? |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-07-27 : 07:52:48
|
| hisorry am not getting your query.. can you explain pls.-------------------------R.. |
 |
|
|
sparrow37
Posting Yak Master
148 Posts |
Posted - 2009-07-27 : 07:59:32
|
| ALTER PROC [dbo].[GetUserDataByEmail]( @EmailAddress VARCHAR(100))ASif exists(SELECT * FROM USERS WHERE EMAIL = @EmailAddress and IsEnable = 0 )BEGINSELECT * FROM USERS WHERE EMAIL = @EmailAddressRETURN 1ENDelse if exists(SELECT * FROM USERS WHERE EMAIL = @EmailAddress and IsEnable = 1 )BEGIN RETURN 2 -- your are already active memberENDelse BEGIN RETURN 0 -- you are not registered please create accountENdif first case is true then a row is returned, if second or third case is true then only a single integer value is returned. means different types of result sets are returned. |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-07-27 : 08:02:12
|
| hiOP is fine.. its working right...what is your query on this..-------------------------R.. |
 |
|
|
sparrow37
Posting Yak Master
148 Posts |
Posted - 2009-07-27 : 08:19:01
|
| pasted above |
 |
|
|
sparrow37
Posting Yak Master
148 Posts |
Posted - 2009-07-27 : 08:58:31
|
| suggestions please ? |
 |
|
|
|
|
|