You are here: Re: Truncate Table On Linked Server? « MsSQL Server « IT news, forums, messages
Re: Truncate Table On Linked Server?

Posted by Erland Sommarskog on 05/15/06 13:38

Neil (nospam@nospam.net) writes:
> Can one use Truncate Table on a linked server table? When I try it, I
> get a message that only two prefixes are allowed. Here's what I'm
> using:
>
> Truncate Table svrname.dbname.dbo.tablename

I guess the error message answers your question.

There is also a good reason for this not being permitted. Truncate Table
is a special operation, that may not make sense on some other data source.
Remember that a linked server does not have to be SQL Server.

If you are on SQL 2005, you can say:

EXEC('TRUNCATE TABLE dbname.dbo.tablename') AT svrname

On earlier versions of SQL Server you are probably better off using DELETE
instead, although it could possible to do it with OPENQUERY.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация