Solved

SQL truncate table on linked server

Posted on 2006-11-01
5
1,173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

632 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