Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pinglu
Starting Member
2 Posts |
Posted - 2012-05-27 : 14:46:01
|
| Hi,Can anyone help me understand the following SQL,SELECT ID,OrchestrationName,LastRunDB,RunStatus,TRIGGERFLAG,ManualExtractEndDate from dbo.IH_CILASTRUNwhere ProjectName = 'DynamicsSync' and OrchestrationName != 'DynamicsSync' and SkipRun != 1AND 0 = (SELECT COUNT(*) from dbo.IH_CILASTRUN where ProjectName = 'DynamicsSync' and RunStatus = 'INPROCESS')The thing that I don't understand is the "AND 0 = (SELECT COUNT(*) from dbo.IH_CILASTRUN where ProjectName = 'DynamicsSync' and RunStatus = 'INPROCESS')", I assume this is not a correlated query, but if it is not, then how do I interpret the result? Thanks in advance. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-27 : 15:04:56
|
| the way its written its not correlated to main query. what it does is it will cause query to return a resultset only if there are no rows satisfying conditions ProjectName = 'DynamicsSync' and RunStatus = 'INPROCESS' in the table dbo.IH_CILASTRUN------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
pinglu
Starting Member
2 Posts |
Posted - 2012-05-27 : 15:24:04
|
Thanks for the reply, now I understand.quote: Originally posted by visakh16 the way its written its not correlated to main query. what it does is it will cause query to return a resultset only if there are no rows satisfying conditions ProjectName = 'DynamicsSync' and RunStatus = 'INPROCESS' in the table dbo.IH_CILASTRUN------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-27 : 15:45:38
|
no problem...you're welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-05-27 : 18:29:14
|
SELECT ID,OrchestrationName,LastRunDB,RunStatus,TRIGGERFLAG,ManualExtractEndDate from dbo.IH_CILASTRUNwhere ProjectName = 'DynamicsSync' and OrchestrationName != 'DynamicsSync' and SkipRun != 1AND NOT EXISTS (SELECT * from dbo.IH_CILASTRUN where ProjectName = 'DynamicsSync' and RunStatus = 'INPROCESS') N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|
|
|