Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Insert only new records to linked server table
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01063084
Message ID:
01063190
Views:
10
This message has been marked as the solution to the initial question of the thread.
I guess NULLs are responsible for your problem. Try
...
	where callid not in(select phoneleadid
		from [67.xx.xxx.xxx].[server1].[dbo].[targettable]
                WHERE phoneleadid IS NOT NULL)
>The following query runs on the SQL server box that has 'sourcetable'. Its function is to add new records to 'targettable' on the remote linked server. It correctly adds rows when I have the column 'phoneleadid' as the primary key for 'targettable'. It runs, but does not add rows, if I change the primary key for 'targettable' and allow nulls in 'phoneleadid'. (There is no primary key on 'sourcetable'.)
>
>Any way to get this to run without having 'phoneleadid' be the primary key for 'targettable'? Would it be enough to disallow nulls in 'phoneleadid'?
>Thanks for any help.
>
>
>insert into [67.xx.xxx.xxx].[server1].[dbo].[targettable]
>	(phoneleadid,pnumber)
>	select callid,localuserid
>	from [sourcetable]
>	where callid not in(select phoneleadid
>		from [67.xx.xxx.xxx].[server1].[dbo].[targettable])
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform