Home All advices
ENPL
Modify date: 2013-01-14 15:47:39

Differences in the methods used to collect the data from the table to the variable

Below are shown the differences in the action of two scripts

sample table

idname
1Berlin
2Paris
3Madryt

solution, in which the script changes the value of the variable

example of a solution

declare
@tmp int
set @tmp = -1
set @tmp = (select ci_id from cities where ci_name = 'London')
select @tmp

result

(No column name)
NULL

solution, in which the script does not change the value of the variable

example of a solution

declare
@tmp int
set @tmp = -1
(select @tmp = ci_id from cities where ci_name = 'London')
select @tmp

result

(No column name)
-1
[ Strona główna ]