all groups > sql server odbc > january 2007 >
You're in the

sql server odbc

group:

Truncate Table On Linked Server (AS400)


Truncate Table On Linked Server (AS400) albelavoro NO[at]SPAM gmail.com
1/25/2007 6:47:56 AM
sql server odbc: Hi,
first of all, sorry for my bad english.
I use SQL SERVER 2000 and I need to use TRUNCATE TABLE on a table
located in a linked server.
This linked server it's an IBM AS/400 and I've got the access from SQL
to AS/400 by a provider called Hit OleDB 400.
If I use DELETE or the other commands like SELECT ecc. works perfectly:

DELETE OPENQUERY(AS400, 'SELECT Codart FROM Prezzi WHERE Codart =
''15146''')

Now I need to TRUNCATE the table "Prezzi" on the "DatiPC" library on
the "AS400" linked server but, if I use:

TRUNCATE TABLE AS400.DatiPC.dbo.Prezzi

I'll get this message:

Server: Msg 117, Level 15, State 1, Line 2
The object name 'server01.database01.dbo.' contains more
than the maximum number of prefixes. The maximum is 2.

How can I do this???

Thanks in advance.
Re: Truncate Table On Linked Server (AS400) albamain
1/29/2007 9:38:04 AM
You cannot perform a TRUNCATE TABLE via linked server since it's SQL Server
specific syntax (i.e. it's not standard SQL).
The best way is to use the DELETE OPENQUERY syntax you've already tried:
this syntax allows to (eventually) save the deleted records to AS400 journal
for recovery.
To speed up the process, you could create a new Stored Procedure on AS400
side which DROPs the table and re-create it.
You can run AS400 SP via linked server using the EXEC syntax.
On HIT Software web site you can find more useful info in the KB section
about Hit OleDB 400.
HTH


[quoted text, click to view]

Re: Truncate Table On Linked Server (AS400) Ross Culver
2/21/2007 11:16:30 AM
Drop the dbo.
AS400 would be like this database01.Prezzi
The server should have already been defined in the ODBC Connection.

Ross


[quoted text, click to view]

AddThis Social Bookmark Button