C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

How to store result of a query in a variable


Posted Date: 01 Dec 2007      Posted By: veeresh narasappa      Member Level: Bronze     Points: 2   Responses: 2



Hi All,

Please tel me how to store result of a query in a variable.
And I want to use that variable in another query's in where condition
Here below is my code.


alter procedure LogProc
(
@UserId varchar(500),
@Password varchar(500)
)
as
Begin
declare @str1 varchar(500)
declare @str2 varchar(500)
declare @str3 varchar(500)
set @str1 =( ' select AstId from UserTable where UserId = ''' + @UserId + ''' and Password = ''' + @Password + '''' )
exec(@str1);
set @str2=(' select RoleID from AstProf where AstId = ''''' + @str1 + '''''')
exec(@str2);
End

exec LogProc 'veeresh','veeresh'





Responses

Author: KVGaneshBabu    01 Dec 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

You should use OUTPUT parameter

alter procedure LogProc
(
@UserId varchar(500) OUTPUT,
@Password varchar(500) OUTPUT
)
Then you should call the other procedure



Author: veeresh narasappa    01 Dec 2007Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

Hi Sir,

This is not working



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : interview questin...
Previous : Query to avoid repeated records
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use