Transact-SQL: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Marius~itwiki (discussione | contributi)
m +collegamenti esterni
Marius~itwiki (discussione | contributi)
aggiunta
Riga 47:
<code>DECLARE</code> dichiara una variabile, attribuendole un nome ed un tipo. Per attribuirle un valore si usa SET, e successivamente la variabile può essere usata utilizzandone nome come riferimento.
 
Questo script dichiara una variabile come intero, la inizializza,e poi uso un <code>WHILE</code> per eseguire un loop.
<!--
 
 
This script declares a variable as an integer, initializes it, then uses <code>WHILE</code> to execute a loop.
 
<pre>
DECLARE @CounterContatore INT
SET @CounterContatore = 10
WHILE @CounterContatore > 0
BEGIN
PRINT 'TheNumero count iscicli: ' + CONVERT(VARCHAR(10), @CounterContatore )
SET @CounterContatore = @CounterContatore - 1
END
</pre>
 
All'interno del loop viene stampato un messaggio che include il valore corrente della variabile, dopo di che il contatore viene decrementato di uno.
The body of the loop will print a message including the value of the variable, and then decrement the counter.
 
<!--
 
A variable may be initialized as the result of a statement, like this: