Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Tempoary Variables in Stored Procedures

Started 1 month ago by MS Forum Newgroup User
Hi all, I'm trying to create a procedure that contains a temp variable that I can use further in the procedure, so that I can use the result from the first query in the second query: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER proc [dbo].[GetDetails] @ID int, @IDName varchar(100), @tempvar varchar(100) as begin Select @IDName AS tempvar from tbl_main where tbl_main.id = @ID SET @...
Site: SQL Server Forum  SQL Server Forum - site profile
Forum: Other SQL Server Topics  Other SQL Server Topics - forum profile
Total authors: 2 authors
Total thread posts: 2 posts
Thread activity: no new posts during last week
Domain info for: sqlmonster.com

Other posts in this thread:

Erland Sommarskog replied 1 month ago
First there is no need for a variable. Write the query as: Select l.username AS UName, isnull(l.useremail,'NA') AS UEmail from tbl_login l join tbl_main m ON m.column_name = l.designation where tbl_login.designation = @ID I here used m.column_name, as it is not clear to me what is the name of the column tbl_main. I also dropped the isnull around username, because of the login does ...

 

Top contributing authors

Name
Posts
MS Forum Newgroup User
1
user's latest post:
Tempoary Variables in Stored...
Published (2009-11-13 23:46:00)
Hi all, I'm trying to create a procedure that contains a temp variable that I can use further in the procedure, so that I can use the result from the first query in the second query: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER proc [dbo].[GetDetails] @ID int, @IDName varchar(100), @tempvar varchar(100) as begin Select @IDName AS tempvar from tbl_main where tbl_main.id = @ID SET @tempvar = tempvar Select...
Erland Sommarskog
1
user's latest post:
Tempoary Variables in Stored...
Published (2009-11-14 21:26:00)
First there is no need for a variable. Write the query as:  Select l.username AS UName,  isnull(l.useremail,'NA') AS UEmail  from  tbl_login l  join  tbl_main m ON m.column_name = l.designation  where tbl_login.designation = @ID I here used m.column_name, as it is not clear to me what is the name of the column tbl_main. I also dropped the isnull around username, because...

Related threads on "SQL Server Forum":

Related threads on other sites:

Thread profile page for "Tempoary Variables in Stored Procedures" on http://www.sqlmonster.com. This report page is a snippet summary view from a single thread "Tempoary Variables in Stored Procedures", located on the Message Board at http://www.sqlmonster.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity