Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 setting the value of multiple records for 1 column
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mgreen84
Yak Posting Veteran

94 Posts

Posted - 02/26/2014 :  13:07:40  Show Profile  Reply with Quote
I'm trying to set the values in a select statement for a it to return two columns with two rows.

example:

ELSE IF (@AreaAdmin = 1 AND @CategoryID = 3)
BEGIN
SELECT 'SPC' AS FilterID
, 'SPC' AS FilterName

*but I also need it to return a 2nd row with the following values
'VZW' AS FilterID and 'VZW' AS FilterName


END


if anyone can help me with this, it would be much appreicated.

mgreen84
Yak Posting Veteran

94 Posts

Posted - 02/26/2014 :  13:22:03  Show Profile  Reply with Quote
Nevermind guys, I decided to just use a table variable and it works fine, Not sure if it's the most effiecnt way to complete the task, so would still be interested in hearing and seeing other ways to have gone about this.


ELSE IF (@AreaAdmin = 1 AND @CategoryID = 3)
declare @FliterTableVar table ( 
	FilterID VARCHAR(3), 
	FilterName nchar(5))

BEGIN
BEGIN
	Insert Into @FliterTableVar (FilterID, FilterName)
      SELECT 'SPC'   AS FilterID
	       , 'SPC'   AS FilterName
	       
	Insert Into @FliterTableVar (FilterID, FilterName)
      SELECT 'VZW'   AS FilterID
	       , 'VZW'   AS FilterName
END	       
SELECT * FROM @FliterTableVar

END	



Thanks

Edited by - mgreen84 on 02/26/2014 13:22:43
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000