|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
truncate table thru a link serverI 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 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 |
|||||||||||||||||||||||