Home All Groups Group Topic Archive Search About

truncate table thru a link server

Author
1 Dec 2005 5:42 PM
culam
I have 2 tables with 500K and 1Million records and need TRUNCATED/LOADED
daily. I cannot truncate thru a link server.
Ex. TRUNCATE TABLE linkedServer.DBName.dbo.tablename

I am forced to use a DELETE command, but it takes too long.  Does anybody
have a better idea or a way to truncate a table remotely.

Thanks,
Lam

Author
1 Dec 2005 6:22 PM
John Bell
Hi

You could use openquery such as

SELECT * FROM  OPENQUERY(linkedServer,'TRUNCATE TABLE DBName.dbo.tablename
SELECT ''OK'';)

But you may want to wrap your processing into a stored procedure on the
remote server and process everything in the one call.

e.g on remote server
CREATE PROCEDURE usp_truncatetablename
AS
    truncate table DBName.dbo.tablename

On local server

EXEC linkedServer.DBName.dbo.usp_truncatetablename

John

Show quote
"culam" wrote:

> I have 2 tables with 500K and 1Million records and need TRUNCATED/LOADED
> daily. I cannot truncate thru a link server.
> Ex. TRUNCATE TABLE linkedServer.DBName.dbo.tablename
>
> I am forced to use a DELETE command, but it takes too long.  Does anybody
> have a better idea or a way to truncate a table remotely.
>
> Thanks,
> Lam

AddThis Social Bookmark Button