Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

Incorrect syntax near the keyword 'where'.

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
bibi92
Asked:
bibi92
  • 3
  • 2
1 Solution
 
BurniePCommented:
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
 
Rajkumar GsSoftware EngineerCommented:
declare @sql1 varchar(max)
set @sql1 = 'delete from ['+ @abonne + '].'+ @Db_ods + '.dbo.MSreplication_subscriptions
where [publication] = ''' + @publication + ''''
execute (@sql1)
print (@sql1)
0
 
Rajkumar GsSoftware EngineerCommented:
The single quotes before where is causing this error
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
bibi92Author Commented:
Thanks bibi
0
 
Rajkumar GsSoftware EngineerCommented:
Glad to help you
Raj
0
 
BurniePCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now