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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Sum of items in two tables not equal. 5 42
Using this function 4 38
SQL Select - identify record discrepancies 1 29
SQL Add Parameter in Variable 4 21
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

679 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