Solved

SQL truncate table on linked server

Posted on 2006-11-01
5
1,144 Views
Last Modified: 2012-06-27

I have the following command

EXECUTE  XXXXXXX.master.dbo.sp_executesql N'TRUNCATE table TEST_RECOVERY.dbo.table1'

that works fine in QA but when added to a DTS package to clear down a table on a linked server I get the following:

Could not connect to server 'xxxxxx' because 'sa' is not defined as a remote login at the server.

The source and target sa pwords match up any idea's?? (Yup I know its bad practice to use sa but give me a break until I get it working 8))

0
Comment
Question by:Netstore
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17850855
::Could not connect to server 'xxxxxx' because 'sa' is not defined as a remote login at the server.

configure the linked server to make the local sa account to the remote sa account.
in that configuration, the passwords don't need to match any longer
0
 
LVL 5

Author Comment

by:Netstore
ID: 17851158
angelII apologies for being an idiot could you give me instructions on how to do that please? Cheers
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 100 total points
ID: 17851198
EXEC sp_addlinkedsrvlogin 'LinkedServerName', 'false', 'sa', 'RemoteUserName', 'RemoteUserPassword'

0
 
LVL 11

Assisted Solution

by:rw3admin
rw3admin earned 150 total points
ID: 17851384
Why are you using linked server inside a DTS package to begin with?, thats an added layer of complexity.

create a brand new database connection in DTS package for your linked server and then use that in your execute SQL task, you dont even have to put
"EXECUTE  XXXXXXX.master.dbo.sp_executesql N'TRUNCATE table TEST_RECOVERY.dbo.table1'"


you can then just do

TRUNCATE table TEST_RECOVERY.dbo.table1
0
 
LVL 5

Author Comment

by:Netstore
ID: 17857104
rw3 thats bang on (What was I thinking...couldn't see the wood for the trees)

anne thanks also for the effor as your solution works as well
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql update 2 35
SQL Server Trigger 8 33
Need help with a query 3 36
Logical Operator should return Integer value in SSIS 9 34
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question