[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

An expression of non-boolean type specified in a context where a condition is expected

Posted on 2011-04-22
2
Medium Priority
?
747 Views
Last Modified: 2012-05-11
Hello,

I want to execute :

'IF (select *  from  ['+@SrvAbonne + '].['+ @DbCible + '].dbo.sysobjects where name = ''MSsubscription_agents'')
then
delete from ['+@SrvAbonne + '].['+ @Dbcible + '].dbo.MSreplication_subscriptions
where [publication] like ''' + @publication + ''' end if' :

An expression of non-boolean type specified in a context where a condition is expected, near 'then'. #4145

But I have this error :
An expression of non-boolean type specified in a context where a condition is expected

Thanks

bibi
0
Comment
Question by:bibi92
2 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 35450869

Use exists

'IF Exists((select *  from  ['+@SrvAbonne + '].['+ @DbCible + '].dbo.sysobjects where name = ''MSsubscription_agents''))
0
 

Author Closing Comment

by:bibi92
ID: 35450977
Thanks bibi
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

872 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