Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet374/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   370   371   372   373   374   375   376   377   ...   443
Bog'liq
BookSQL

 

CHAPTER 10

 

Programmable Objects



 

 343

Batches and Variables

A variable is local to the batch in which it is defined. If you try to refer to a variable that was defined 

in another batch, you will get an error saying that the variable was not defined. For example, the fol-

lowing code declares a variable and prints its content in one batch, and then tries to print its content 

from another batch.

DECLARE @i AS INT; 

SET @i = 10; 

-- Succeeds 

PRINT @i; 

GO 


 

-- Fails 

PRINT @i;

The reference to the variable in the first PRINT statement is valid because it appears in the same 

batch where the variable was declared, but the second reference is invalid. Therefore, the first PRINT 

statement returns the variable’s value (10), whereas the second fails. Here’s the output returned from 

this code.

10 


Msg 137, Level 15, State 2, Line 3 

Must declare the scalar variable "@i".




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   370   371   372   373   374   375   376   377   ...   443




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish