Timcwilcox
Programmer
I am very new to MSSQL7 and i am stuck with a program that appears to be very easy, but which i can not get to work.
I have the following SQL script (I appologise for the TABLE/COLUMN names, but this is someone elses database)
insert into XLABELS
SELECT CONVERT(numeric, (MP640100.MP64004 / CONVERT(numeric, SC010100.SC01014))) AS [NOBAGS],
MP640100.MP64001 AS [WORDER],
MP640100.MP64002 AS [STCODE],
MP640100.MP64004 AS [ORDQTY],
SC010100.SC01014 AS [UD5],
SC010100.SC01132 AS [EAN],
SUBSTRING(SC010100.SC01001, 4, 1) AS [COLOUR]
FROM SC010100 INNER JOIN MP640100 ON SC010100.SC01001 = MP640100.MP64002
This is working OK if the WORDER does not exist in XLABELS table, as this is has a UNIQUE index this is quite correct.
How do i get the script to only insert records into the XLABELS table if it does not exist?
Many Thanks
Tim
I have the following SQL script (I appologise for the TABLE/COLUMN names, but this is someone elses database)
insert into XLABELS
SELECT CONVERT(numeric, (MP640100.MP64004 / CONVERT(numeric, SC010100.SC01014))) AS [NOBAGS],
MP640100.MP64001 AS [WORDER],
MP640100.MP64002 AS [STCODE],
MP640100.MP64004 AS [ORDQTY],
SC010100.SC01014 AS [UD5],
SC010100.SC01132 AS [EAN],
SUBSTRING(SC010100.SC01001, 4, 1) AS [COLOUR]
FROM SC010100 INNER JOIN MP640100 ON SC010100.SC01001 = MP640100.MP64002
This is working OK if the WORDER does not exist in XLABELS table, as this is has a UNIQUE index this is quite correct.
How do i get the script to only insert records into the XLABELS table if it does not exist?
Many Thanks
Tim