Hi.
Is in T-SQL possible to do something like switch in PHP?
www.php.net/switch
I have this code:
And I want convert it to:
In MSDN I found there is this possibility only in SELECT statement. But I dont want to return anything into SELECT. I only want to run T-SQL commands.
Please can you show me how to do it, if it is possible?
Thank you!
Is in T-SQL possible to do something like switch in PHP?
www.php.net/switch
I have this code:
Code:
declare @variable int
set @variable=3
if @variable=1
begin
print 'a'
print 'another t-sql commands continue...'
end
else if @variable=2
begin
print 'b'
print 'another t-sql commands continue...'
end
else if @variable=3
begin
print 'c'
print 'another t-sql commands continue...'
end
And I want convert it to:
Code:
CASE
WHEN @variable=1 THEN
begin
print 'a'
print 'another t-sql commands continue...'
end
WHEN @variable=2 THEN
begin
print 'b'
print 'another t-sql commands continue...'
end
WHEN @variable=3 THEN
begin
print 'b'
print 'another t-sql commands continue...'
end
ELSE
begin
print 'default'
print 'another t-sql commands continue...'
end
END
In MSDN I found there is this possibility only in SELECT statement. But I dont want to return anything into SELECT. I only want to run T-SQL commands.
Please can you show me how to do it, if it is possible?
Thank you!