Wednesday, June 3, 2009

Access Table withought linking Servers

Select A.* From OPENROWSET('MSDASQL', 'DRIVER={SQL SERVER};SERVER=name\instance;UID=user;PWD=password',
'SELECT * FROM pubs.dbo.authors') AS A Where A.MaintenanceDate <> MaintenanceDate




Select A.* From OPENROWSET('MSDASQL',
'Driver={SQL SERVER};SERVER=server\instance;UID=user;PWD=pass',
'SELECT * FROM database.dbo.table') as A
Right Outer Join database.dbo.table As B on A.PlantID = B.PlantID
AND A.RuleType = B.RuleType AND A.RulePrefix = B.RulePrefix and
A.RuleSuffix = B.RuleSuffix
Where A.MaintenanceDate <> B.MaintenanceDate




SELECT A.*
FROM database.dbo.table AS B
LEFT JOIN OPENROWSET('MSDASQL', 'Driver={SQL SERVER};SERVER=server\instance;UID=user;PWD=pass'
,'SELECT * FROM database.dbo.table') AS A
ON B.PlantID = A.PlantID AND B.RuleType = A.RuleType AND B.RulePrefix = A.RulePrefix
AND B.RuleSuffix = A.RuleSuffix AND B.MaintenanceDate <> A.MaintenanceDate