SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Select syntax error


Select syntax error

Author
Message
ronsql
ronsql
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 488
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.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89825 Visits: 45284
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, MVP, M.Sc (Comp Sci)
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


davidandrews13
davidandrews13
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1078 Visits: 4542
you
ronsql
ronsql
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 488
Thanks for early reply,

if there is more than one row in workflow_activity table.

what changes can i do in the code?

Thanks.
Ramesh Saive
Ramesh Saive
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3560 Visits: 2643
What exactly are you trying to do with that code? Only then, we can help you re-write that code correctly.

--Ramesh


ronsql
ronsql
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 488
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,
GilaMonster
GilaMonster
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89825 Visits: 45284
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, MVP, M.Sc (Comp Sci)
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search