Sql server® 2012 t-sql fundamentals


Statements That Cannot Be Combined in the Same Batch



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

Statements That Cannot Be Combined in the Same Batch

The following statements cannot be combined with other statements in the same batch: CREATE 



DEFAULTCREATE FUNCTION, CREATE PROCEDURECREATE RULECREATE SCHEMACREATE 

TRIGGER, and CREATE VIEW. For example, the following code has an IF statement followed by a 

CREATE VIEW statement in the same batch and therefore is invalid.

IF OBJECT_ID('Sales.MyView', 'V') IS NOT NULL DROP VIEW Sales.MyView; 

 

CREATE VIEW Sales.MyView 



AS 

 

SELECT YEAR(orderdate) AS orderyear, COUNT(*) AS numorders 



FROM Sales.Orders 

GROUP BY YEAR(orderdate); 

GO

An attempt to run this code generates the following error.



Msg 111, Level 15, State 1, Line 3 

'CREATE VIEW' must be the first statement in a query batch.

To get around the problem, separate the IF and CREATE VIEW statements into different batches by 

adding a GO command after the IF statement.

www.it-ebooks.info



344  

Microsoft SQL Server 2012 T-SQL Fundamentals




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   371   372   373   374   375   376   377   378   ...   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