December 1, 2010 at 1:50 pm
Is there an alternate way to query this to make it fast.
insert into dbo.emp_A
(Column1,Column2,Column3,Column4,Column5)
Select Column1,Column2,Column3,Column4,Column5
From dbo.emp_A Where EMP_state = 'PA'
Except Select Column1,Column2,Column3,Column4,Column5
From Obbeaver.RevProd.dbo.emp_A
go
December 1, 2010 at 2:17 pm
If one of those columns is a PK, you could try:
;
WITH CTE AS
(
SELECT PK-COLUMN From dbo.emp_A Where EMP_state = 'PA'
EXCEPT
SELECT PK-COLUMN From Obbeaver.RevProd.dbo.emp_A
)
INSERT INTO dbo.emp_A
(Column1,Column2,Column3,Column4,Column5)
Select Column1,Column2,Column3,Column4,Column5
From dbo.emp_A
JOIN CTE ON emp_A.PK-COLUMN = CTE.PK-COLUMN;
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply