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 |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2009-09-02 : 14:02:12
|
Inserting multiple records:DECLARE @NewInv INT SET @NewInv = (SELECT InvID FROM InvTable) INSERT INTO newTable( custid, Inv) SELECT CustomerID, @NewInv FROM #tempTable Now if CustomerID is not greater than 0, @NewInv must = NULLJust can't seem to get it working right so I stripped it downto the basics here.Suggestions?Thanks,Zath |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-02 : 14:04:12
|
| [code]INSERT INTO newTable( custid, Inv) SELECT CustomerID,CASE WHEN CustomerID >0 THEN @NewInv ELSE NULL END FROM #tempTable[/code] |
 |
|
|
|
|
|