I need to connect to server b from server a using sql syntax to truncate a table. I cannot add it as a linked server. I've seen you can use openrowset but I need to truncate a table and I don't know how to do that. Any ideas?
SELECT * FROM OPENDATASOURCE('SQLNCLI', 'Data Source=London\Payroll;Integrated Security=SSPI') .AdventureWorks2012.HumanResources.Employee
andrewsmd
2:02 pm on Jul 26, 2012 (gmt 0)
Yes, I was actually going to post back today, that's exactly what I used. I just had to create a stored procedure because I needed to truncate tables. So create the sp to truncate the tables on the actual database, and then from the other server EXEC OPENDATASOURCE('SQLNCLI','Data Source=SERVER\INSTANCE;Initial Catalog=dbName;User Id=user;Password=pass').[dbName].dbo.spName