SQLTeam.com | Weblogs | Forums

Error when Using 4 part naming


#1

This is 2008 R2 SP2

This gives error: The object name 'DBAUTIL.DatabaseInventory.dbo.DatabaseObjects' contains more than the maximum number of prefixes.'

Truncate table [Server1].[Database1].[dbo].[Table1]

But when I use Delete From it works fine.

delete from [Server1].[Database1].[dbo].[Table1]

Can anyone tell me WHY the truncate stmt fails?
Thanks, Jack


#2

TRUNCATE TABLE is DDL and doesn't support it. You can work around it by creating a stored procedure in that remote database and having the TRUNCATE in there. You would execute the stored proc via the 4 part name.

For more details: http://dba.stackexchange.com/questions/60973/why-truncate-table-cannot-use-four-part-name


#3

Thank you, Tara. I'll just use the Delete From technique. It's not a large table.