MulaiMulai sekarang secara gratis

Creating and using variables

In T-SQL, to create a variable you use the DECLARE statement. The variables must have an at sign (@) as their first character. Like most things in T-SQL, variables are not case sensitive. To assign a value to a variable, you can either use the keyword SET or a SELECT statement, then the variable name followed by an equal sign and a value.

Latihan ini adalah bagian dari kursus

Intermediate SQL Server

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

-- Declare the variable (a SQL Command, the var name, the datatype)
___

-- Set the counter to 20
___

-- Select the counter
SELECT @counter
Edit dan Jalankan Kode