Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
1,739 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
[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
3 Comments
 
LVL 13

Accepted Solution

by:
devlab2012 earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

604 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