Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hello Friends,

Recently i am trying following Query, but i cant get output..
So can anyone help me out for Output..

I have Query Like this

SQL
DECLARE @i BIGINT = 1
SELECT A = ( CASE WHEN 1 = 1 THEN @i+=1 ELSE 0 END )

I want output 2 after execution of this Query..
Means can i increate integer value With @i++ or @i+=1 or etc??
If not then what should i have to do in this case??
Is this possible?? Please help as early as possible..
Thanking You all.

What I have tried:

SQL
DECLARE @i BIGINT = 1
SELECT A = ( CASE WHEN 1 = 1 THEN @i+=1 ELSE 0 END )
Posted
Updated 7-Apr-16 3:20am

1 solution

DECLARE @i BIGINT = 1
SELECT A = ( CASE WHEN 1 = 1 THEN @i+1 ELSE 0 END )

use this
 
Share this answer
 
Comments
Kiran Akabari 8-Apr-16 1:06am    
Thank you my friend..
But there in an issue in this way..
i also want a value of @i = 2 after executing query..
Thats why i have to make increment in select query... hope you understand my point..

please help me if any suggestion...
Nigam,Ashish 8-Apr-16 1:46am    
DECLARE @i BIGINT = 1
SELECT @i = ( CASE WHEN 1 = 1 THEN @i+1 ELSE @i END )
select @i

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900