SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mgreen84
Yak Posting Veteran

64 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

64 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000