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.
Author |
Topic |
raindear
Yak Posting Veteran
64 Posts |
Posted - 2014-01-23 : 13:05:34
|
HII am currently using this statementDELETE FROM ProductCustomerLevel WHERE CustomerLevelID IN (5, 7)INSERT ProductCustomerLevel (ProductID,CustomerLevelID)SELECT ProductID,CustomerLevelFROM dbo.Product pCROSS JOIN ( SELECT 5 AS CustomerLevel UNION ALL SELECT 7 )cIf I wanted to add another Customer level to the query (number 8 for example)I try thisDELETE FROM ProductCustomerLevel WHERE CustomerLevelID IN (5, 7, 8)INSERT ProductCustomerLevel (ProductID,CustomerLevelID)SELECT ProductID,CustomerLevelFROM dbo.Product pCROSS JOIN ( SELECT 5 AS CustomerLevel UNION ALL SELECT 7 SELECT 8 )cBut get this error. Do the SELECT 7 and SELECT 8 have to be on the same line? if so how?Msg 156, Level 15, State 1, Line 16Incorrect syntax near the keyword 'SELECT'. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-23 : 13:10:22
|
it should be thisDELETE FROM ProductCustomerLevel WHERE CustomerLevelID IN (5, 7, 8)INSERT ProductCustomerLevel (ProductID,CustomerLevelID)SELECT ProductID,CustomerLevelFROM dbo.Product pCROSS JOIN (SELECT 5 AS CustomerLevel UNION ALLSELECT 7 UNION ALLSELECT 8)c ie each record separated by UNION ALL------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
raindear
Yak Posting Veteran
64 Posts |
Posted - 2014-01-23 : 13:13:32
|
THANKS! |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-23 : 13:16:22
|
wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|
|
|