Solved

Incorrect syntax near the keyword 'where'.

Posted on 2011-02-13
6
369 Views
Last Modified: 2012-05-11
Hello,

I try to execute this script :
declare @sql1 varchar(max)
set @sql1 = 'delete from ['+@abonne + '].'+ @Db_ods + '.dbo.MSreplication_subscriptions'
where [publication] = '''+@publication+'''''
execute (@sql1)
print (@sql1)

Msg 156, Level 15, State 1, Procedure drop_repl, Line 84
Incorrect syntax near the keyword 'where'.

Thanks
bibi
0
Comment
Question by:bibi92
  • 3
  • 2
6 Comments
 
LVL 16

Expert Comment

by:BurnieP
ID: 34883562
Hi, you have a non terminated string, you need to add the where part also.

set @sql1 = 'delete from ['+@abonne + '].'+ @Db_ods + '.dbo.MSreplication_subscriptions' + ' where [publication] = '''+@publication+''''

Might
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 500 total points
ID: 34883583
declare @sql1 varchar(max)
set @sql1 = 'delete from ['+ @abonne + '].'+ @Db_ods + '.dbo.MSreplication_subscriptions
where [publication] = ''' + @publication + ''''
execute (@sql1)
print (@sql1)
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34883587
The single quotes before where is causing this error
0
Industry Leaders: 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!

 

Author Closing Comment

by:bibi92
ID: 34883602
Thanks bibi
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34885224
Glad to help you
Raj
0
 
LVL 16

Expert Comment

by:BurnieP
ID: 34885238
I don't understand why my answer was not considerated, since I said the same thing Raj said, but 8 minutes earlier.

I guess it's the luck of the draw.

Cheers,
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how would you excute a sproc on another database on the fly 9 28
MS SQL Sever Import/export problem 7 44
Using this function 4 38
How can I find this data? 3 23
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…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.

680 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