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,681 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

831 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