Solved

Incorrect syntax near the keyword 'where'.

Posted on 2011-02-13
6
374 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
[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
  • 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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

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

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.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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.

751 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