Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

WHERE [column name] NOT IN check after each insert Expand / Collapse
Author
Message
Posted Wednesday, January 9, 2013 7:20 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, September 18, 2014 7:09 AM
Points: 878, Visits: 2,395
atapia_

Nice piece of code providing the table was blank, but what happens when #New_Table already contains data as per below.

Insert into #New_Table
Values (1,'0000000000')
,(2, '1111111111')
,(3, '1111111111')
,(4, '2222222222')
,(5, '3333333333')
,(6, '2222222222')

the code provided would insert 3 more rows of 111111111, 2222222222 categories, thus breaking the Max of 3 rows per National_code.

The reason for this is that you dont take account of existing rows in New_Table which is a possibility according to the original poster.


_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1404775
Posted Wednesday, January 9, 2013 8:16 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, January 10, 2013 5:15 AM
Points: 339, Visits: 71
Really, did not see that consideration.

Thxs!


Ing. Aneurys Tapia González
DBA + BI Architect
Dominican Republic
atapia@outlook.com | admin@atapia.net
http://sqlservermasbi.wordpress.com
http://atapia.net

Post #1404821
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse