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 2008 Forums
 Transact-SQL (2008)
 setting the value of multiple records for 1 column

Author  Topic 

mgreen84
Yak Posting Veteran

94 Posts

Posted - 2014-02-26 : 13:07:40
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 - 2014-02-26 : 13:22:03
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
Go to Top of Page
   

- Advertisement -