Solved

Incorrect syntax near the keyword 'where'.

Posted on 2011-02-13
6
362 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
Comment Utility
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
Comment Utility
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
Comment Utility
The single quotes before where is causing this error
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Closing Comment

by:bibi92
Comment Utility
Thanks bibi
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
Comment Utility
Glad to help you
Raj
0
 
LVL 16

Expert Comment

by:BurnieP
Comment Utility
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

772 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

14 Experts available now in Live!

Get 1:1 Help Now