Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Select syntax error Expand / Collapse
Author
Message
Posted Friday, March 20, 2009 9:25 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 12:40 PM
Points: 20, Visits: 485
declare @sequence_number int
set @sequence_number = select case when workflow_activity_type_identifier = 197 then '1'
else
case when workflow_activity_type_identifier = 203 then '1'
else(select count(*) from workflow_activity where workflow_activity_type_identifier in (200,201)
and workflow_activity_identifier = @workflow_activity_identifier
and workflow_identifier=@workflow_identifier)
end
end
from workflow_activity

I m getting ERROR : Incorrect syntax near the keyword 'select'.

what is that error?

thanks.
Post #680483
Posted Friday, March 20, 2009 9:33 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:26 AM
Points: 42,763, Visits: 35,856
Drop the SET and do the assignment as part of the select

declare @sequence_number int
select @sequence_number =
case
when workflow_activity_type_identifier = 197 then '1'
else
case when workflow_activity_type_identifier = 203 then '1'
else(select count(*)
from workflow_activity
where workflow_activity_type_identifier in (200,201)
and workflow_activity_identifier = @workflow_activity_identifier
and workflow_identifier=@workflow_identifier)
end
end
from workflow_activity

Just be warned, if there's more than 1 row in the workflow_activity table, it's not easy to say which row will be the one evaluated for the variable.

What, exactly, are you trying to do with this statement?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #680491
Posted Friday, March 20, 2009 9:33 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, August 14, 2014 9:56 AM
Points: 575, Visits: 3,390
you
Post #680493
Posted Friday, March 20, 2009 10:21 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 12:40 PM
Points: 20, Visits: 485
Thanks for early reply,

if there is more than one row in workflow_activity table.

what changes can i do in the code?

Thanks.
Post #680538
Posted Friday, March 20, 2009 10:34 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, October 21, 2013 12:32 AM
Points: 2,556, Visits: 2,593
What exactly are you trying to do with that code? Only then, we can help you re-write that code correctly.

--Ramesh

Post #680556
Posted Friday, March 20, 2009 11:35 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 12:40 PM
Points: 20, Visits: 485
i created stored procedure fro migrating the data from one sqlserver databse another sqlserver database.

My task is ther is workflow of xxxxxx.

i have to display sequence no increments based on the no of times the borrower completed the task(activity).

i have different task no's like 1,2,3,4

Here 1 and 2 tasks should do one time,the 3 and 4 can repeat multiple times.

this is the req.

i written the query in my post.

thanks,
Post #680609
Posted Friday, March 20, 2009 1:53 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:26 AM
Points: 42,763, Visits: 35,856
Can you explain in a bit more detail please. Maybe with some sample data and desired results.

Read this to see the best way to post this to get quick responses.
http://www.sqlservercentral.com/articles/Best+Practices/61537/



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #680681
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse