Kamis, 27 April 2017

Fungsi String SQL

CHARINDEX(string1, string2 )
fungsi : menentukan posisi awal (int) karakter string1 di dalam string2
contoh :
--cari karakter yg mengandung tanda 1 petik ' 
select * from tabel 1  where kolom1  like '%''%'
-- cari karakter tanda petik o tanda petik   'o'
select * from tabel1  where kol2  like '%''o''%'

select charindex('''',kol1), kol1 , len(kol1), left(kol1 ,charindex('''',kol1) -1 )+' '+right(kol1, len(kol1 )-charindex('''',kol1 )) from tabel1   where kol1   like '%''%'

select charindex('''o''',kec),kec, len(kec), left(kec,charindex('''o''',kec) -1 )+' o '+right(kec,len(kec)-charindex('''o''',kec)-2) from tabel1  where kec like '%''o''%'

select charindex('''',kec),kec, len(kec),left(kec,charindex('''',kec) -1 )+' '+right(kec,len(kec)-charindex('''',kec)) from tabel1  where kec like '%''%'


CHAR(int)  
fungsi :  character nilai kode ascii

Tidak ada komentar:

Posting Komentar