Solved

SQL truncate table on linked server

Posted on 2006-11-01
5
1,105 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 142

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now