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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Set multiple variable values

Author  Topic 

tpayne
Starting Member

18 Posts

Posted - 2008-10-15 : 10:42:43
Is there a way to set the values of multiple variables using Select in one statement?

I would like to do something like this.

Select @cnt, @Name = Count(*), IDRIterationName
From tblIDRIterations
Where IDRIteraionName = @IDRIterationName

Thanks

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-10-15 : 10:57:07
yes you can very well do that, but your query syntax here is wrong (just in case if its the actual query you're using).
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-15 : 10:57:51
may be this is what you want
Select @cnt= Count(*), @Name = IDRIterationName
From tblIDRIterations t
Where t.IDRIteraionName = @IDRIterationName
GROUP BY t.IDRIteraionName
Go to Top of Page

tpayne
Starting Member

18 Posts

Posted - 2008-10-15 : 11:07:43
Thanks!!

This is by far the best online forum I have seen!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-15 : 11:09:25
quote:
Originally posted by tpayne

Thanks!!

This is by far the best online forum I have seen!!


welcome
Go to Top of Page
   

- Advertisement -