kdeutsch
asked on
limit Db insert on ID
This worked for another table but does not seem to work for this insert statement, basically i don't want to insert into the other table if the SSAN already exists in the table. What amd I doing wrong.
Insert Personnel.dbo.tblPersonnel (strSSN, strLName, strFName, strMName)
Select LTRIM(RTRIM(Replace(SSAN, CHAR(160), ''))) SSAN,
Substring(Name, 1, charindex(' ', name, 1)-1) Last,
Substring(Name, charindex(' ', name, 1)+1, charindex(' ', name, charindex(' ', Name, 1)+1)-charindex(' ', name, 1)-1) First ,
Case charindex(' ', Name, charindex(' ', Name, charindex(' ', Name, 1)+1)+1) when 0 then '' else
Substring(Name, charindex(' ', Name, charindex(' ', Name, 1)+1)+1, charindex(' ', Name, charindex(' ', Name, charindex(' ', Name, 1)+1)+1)-charindex(' ', name, charindex(' ', Name, 1)+1)-1) End Middle
FROM [Personnel].[dbo].[tblTemp] where not Exists (Select null from tblPersonnel where SSAN = strSSN)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER