Sql server® 2012 t-sql fundamentals


producing Tables of numbers



Download 10,93 Mb.
Pdf ko'rish
bet154/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   150   151   152   153   154   155   156   157   ...   443
Bog'liq
BookSQL

producing Tables of numbers

One situation in which cross joins can be very handy is when they are used to produce a result set 

with a sequence of integers (1, 2, 3, and so on). Such a sequence of numbers is an extremely powerful 

tool that I use for many purposes. By using cross joins, you can produce the sequence of integers in a 

very efficient manner.

You can start by creating a table called Digits with a column called digit, and populate the table 

with 10 rows with the digits 0 through 9. Run the following code to create the Digits table in the 

TSQL2012 database (for test purposes) and populate it with the 10 digits.

USE TSQL2012; 

IF OBJECT_ID('dbo.Digits', 'U') IS NOT NULL DROP TABLE dbo.Digits; 

CREATE TABLE dbo.Digits(digit INT NOT NULL PRIMARY KEY); 

 

INSERT INTO dbo.Digits(digit) 



  VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 

 

SELECT digit FROM dbo.Digits;



This code also uses an INSERT statement to populate the Digits table. If you’re not familiar with the 

syntax of the INSERT statement, see Chapter 8, “Data Modification,” for details. 

The contents of the Digits table are shown here.

digit 


----------- 







9

www.it-ebooks.info





Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   150   151   152   153   154   155   156   157   ...   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