SQL Rehberi – Hazır Fonksiyonlar – 1

SQL’de işlemlerimizi daha kolay yapmamamızı sağlayan birçok fonksiyon bulunmaktadır. Çoğu zaman lazım olan bu fonksiyonları tek tek açıklamaya çalışacağım. Umarım faydalı olur.

ascii()

Açıklama: Girilen karakterlerin en solundakinin ascii numarsını döndürür.

Yazılış: int = ASCII ( karakter_girişi )

Örnek:

select ascii(‘ABC’) — 65
select ascii(‘A’) — 65
select ascii(‘Z’) — 65
select ascii(‘a’) — 97
select ascii(‘z’) — 122
select ascii(‘0’) — 48
select ascii(‘9’) — 57
select ascii(‘_’) — 95
select ascii(‘ ‘) — 32

char()

Açıklama: Girilen sayının ascii karakter karşılığını döndürür.

Yazılış: char= CHAR ( sayı )

Örnek:

select char(ascii(‘A’))  — A
select char(65)  — A
select char(145) — Sol tek tırnak: ‘
select char(146) — Sağ tek tırnak: ’

Not:

SQL: char(13) = satır başı, char(10) = satır atlama.
VB’deki: ‘vbCrLf’ veya Javascript/c#’daki \n gibi
Örnek:
Print ‘Kod listesi: ‘ + char(13) + char(10) + ‘A = Selam 1’ + char(13) + char(10) + ‘B = Selam 2’

Sonuç:

Kod listesi:
A = Selam 1
B = Selam 2

select nchar(65) — A
select unicode(‘A’) — 65

SQL’de ascii listesi almak için aşağıdaki komutu kullanabiliriz:

declare @strValue varchar(255)
declare @intCount int
declare @intCountMax int
set @intCount = 0
set @intCountMax = 255
forloop_begin:
  set @strValue = (select (convert(varchar(15),@intCount) + '-' + char( @intCount ) ))
  print @strValue
  set @intCount = @intCount + 1
  if ( @intCount <= @intCountMax ) begin
    goto forloop_begin
  end
forloop_end:

charindex()

Açıklama: girdiğimiz yazının içinden belirlediğimiz kısmın başlangıç karakterini döndürür, eğer yoksa 0 döner.

Yazılış: int = CHARINDEX ( expression1 , expression2 [ , start_location ] )

expression1 – Aranılacak olan text
expression2 – içinde arama yapılacak text.
Start_location = 0 veya negatif = başlangıç.

Örnek :
select charindex( ‘Selam’, ‘Yeniden Selam Herkese’)  — 7
select charindex( ‘/’, ‘http://www.ftorun.com/’,8) — 22

difference()

Açıklama: iki soundex değerini karşılaştırıp 1 – 4 arasında bir numara dödürür. Birbirlerine olan benzerliklerine göre 4’e yakın bir değer verir.

Soundex nedir: Bir kelimeden fonetik bir kod cikarma yontemidir. SQL’de SOUNDEX() komutu ile verdiğimizde bize 4 haneli soundex değeri, difference ise iki soundex degerini kiyaslayarak iki kelimenin birbirine ne kadar yakin okundugunu cikarilabilir.

Yazılış:

int = DIFFERENCE ( yazi_1 , yazi_2 )

Örnek:

SELECT SOUNDEX(‘Hello’) — H400
select DIFFERENCE(‘Hello’,’Hello’) — 4

SELECT SOUNDEX(‘ankara’) — A526
select DIFFERENCE(‘ankara’,’ankara’) — 4

SELECT SOUNDEX(‘ali’) — A400
SELECT SOUNDEX(‘veli’) — V400
select DIFFERENCE(‘ali’,’veli’) — 3

SELECT SOUNDEX(‘abcdefg’) — A123
SELECT SOUNDEX(‘tuvwxyz’) — T122
select DIFFERENCE(‘abcdefg’,’tuvwxyz’) — 2  (1 "1" + 1 "2" = 2)

SELECT SOUNDEX(‘dog’) — D200
SELECT SOUNDEX(‘dot’) — D300
select DIFFERENCE(‘dog’,’dot’) — 3  (1 "D" ve 2 "0" = 3)

select SOUNDEX(‘hakan’) — H250
select SOUNDEX(‘melih’) — M400
select DIFFERENCE(‘hakan’,’melih’) — 1  (Soundex değerlerinden sadece sondaki 0 aynı olduğu için 1.)

–Soundex değerlerinin hepsi aynıysa geriye 4 döner.
select SOUNDEX(‘1’) — 0000
select SOUNDEX(‘2’) — 0000
select SOUNDEX(’20’) — 0000
select SOUNDEX(‘100’) — 0000
select DIFFERENCE(‘1′,’2’) — 4
select DIFFERENCE(’20’,’100′) — 4

1.236 thoughts on “SQL Rehberi – Hazır Fonksiyonlar – 1”

  1. Geri bildirim: meritking

  2. Geri bildirim: meritking

  3. Geri bildirim: meritking

  4. Geri bildirim: meritking

  5. Geri bildirim: kingroyal

  6. Geri bildirim: meritking

  7. Geri bildirim: kingroyal

  8. brillx casino
    https://brillx-kazino.com
    Добро пожаловать в увлекательный мир азарта и развлечений на официальном сайте Brillx Казино! Если вы ищете захватывающий опыт игры в игровые аппараты, то ваш поиск завершен. Brillx Казино – это не просто блистательный выбор игр, это настоящее путешествие в мир азарта и возможностей.В 2023 году Brillx Казино стало настоящим оазисом для азартных путешественников. Подарите себе незабываемые моменты радости и азарта. Не упустите свой шанс сорвать куш и стать частью легендарной истории на страницах брилкс казино.

  9. Geri bildirim: grandpashabet

  10. Geri bildirim: meritking

  11. Разрешение на строительство — это официальный письменное удостоверение, предоставляемый управомоченными структурами государственного аппарата или субъектного самоуправления, который дает возможность начать стройку или выполнение строительных операций.
    Разрешение на строительство определяет юридические принципы и нормы к строительству, включая предусмотренные типы работ, предусмотренные материалы и способы, а также включает строительные инструкции и комплекты безопасности. Получение разрешения на строительный процесс является необходимым документов для строительной сферы.

  12. To understand actual scoop, ape these tips:

    Look representing credible sources: http://ourmetals.com/includes/pages/what-time-of-day-do-doctors-call-with-bad-news.html. It’s material to guard that the newscast roots you are reading is worthy and unbiased. Some examples of reputable sources include BBC, Reuters, and The Modish York Times. Review multiple sources to get back at a well-rounded view of a precisely statement event. This can help you listen to a more complete facsimile and dodge bias. Be aware of the perspective the article is coming from, as even respected report sources can compel ought to bias. Fact-check the low-down with another fountain-head if a expos‚ article seems too staggering or unbelievable. Always pass unshakeable you are reading a advised article, as news can substitute quickly.

    Nearby following these tips, you can become a more in the know scandal reader and more intelligent apprehend the everybody here you.

  13. To understand actual dispatch, adhere to these tips:

    Look fitted credible sources: https://drsophie.co.uk/wp-content/pages/when-repeated-1968-name-in-the-news-crossword.html. It’s eminent to secure that the expos‚ source you are reading is worthy and unbiased. Some examples of reliable sources subsume BBC, Reuters, and The Fashionable York Times. Announce multiple sources to get back at a well-rounded sentiment of a discriminating low-down event. This can better you listen to a more complete picture and keep bias. Be cognizant of the angle the article is coming from, as even respectable news sources can have bias. Fact-check the information with another origin if a news article seems too unequalled or unbelievable. Many times pass sure you are reading a fashionable article, as expos‚ can substitute quickly.

    Close to following these tips, you can fit a more aware of news reader and more wisely understand the cosmos everywhere you.