Solved

sql error on sp_dropserver while running whole query or debugging, but not when executing the individual line

Posted on 2011-03-23
3
1,663 Views
Last Modified: 2012-05-11
In SQL Server 2008, I hae the following line just before adding the linked server back:

sp_dropserver 'SvrExcel', 'droplogins'

I realize I could check for the existence of SvrExcel, but this named server always exists for me because whenever I do one of many small data manipulation jobs, I overwrite it with the next one.  I get the following message when I run it by executing the whole sql query, and also when I use the debug feature.  

Msg 102, Level 15, State 1, Line 19
Incorrect syntax near 'sp_dropserver'.

However, I do not get the error message, and the command is successful, when I merely select the line and execute the one line.

Any clue as to why it would be showing an error while executing the whole query but not when executing the one line?

TIA

jr
0
Comment
Question by:jruhe
3 Comments
 
LVL 13

Accepted Solution

by:
devlab2012 earned 500 total points
ID: 35204200
Change the line to:

EXEC sp_dropserver 'SvrExcel', 'droplogins'
0
 
LVL 9

Expert Comment

by:kaminda
ID: 35204362
Try terminating the line before this statement with a semi colon (;). Sometimes it is the case.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35206417
As previously indicated the "EXEC" is required (no point please)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
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…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

705 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

17 Experts available now in Live!

Get 1:1 Help Now