SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 truncate a table on a linked server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

herbau
Starting Member

Australia
3 Posts

Posted - 10/17/2012 :  16:21:56  Show Profile  Reply with Quote
I’m trying to truncate a table on a linked server. I’ve given myself all possible permissions on the linked server.
I can run:
SELECT * FROM linkedServer.import.dbo.SafetyStockTime
But when I run:
TRUNCATE TABLE linkedServer.import.dbo.SafetyStockTime
I get the error:
Cannot find the object "SafetyStockTime" because it does not exist or you do not have permissions.
So I know it exists, and I’ve assigned myself all possible permissions. Any help as to what I'm missing??
Thanks

tkizer
Almighty SQL Goddess

USA
36797 Posts

Posted - 10/17/2012 :  16:48:11  Show Profile  Visit tkizer's Homepage  Reply with Quote
You can't truncate a table over a linked server since truncate is DDL and not DML. You'll need to use delete instead or connect to the server directly rather than through the linked server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

robvolk
Most Valuable Yak

USA
15659 Posts

Posted - 10/17/2012 :  18:51:47  Show Profile  Visit robvolk's Homepage  Reply with Quote
One option you can try is to create a stored procedure on the linked server that performs the TRUNCATE TABLE, then execute it via 4-part name:

EXEC linkedServer.import.dbo.TruncateProcedure

In SQL Server 2008 (not sure about previous versions), you can use the AT clause of the EXECUTE command:

EXEC ('TRUNCATE TABLE import.dbo.TruncateProcedure') AT linkedServer

See Books Online for more details under "EXECUTE".
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000