char(n) --長度固定 不可變 非Unicode 字符數據 n 必須是一個介于 1 和 8,000 之間的數值
nchar(n) --長度固定 不可變 Unicode 字符數據 n 的值必須介于 1 與 4,000 之間,字節的存儲大小是所輸入字符個數的兩倍。
varchar(n) --長度可變 非Unicode 字符數據 n 必須是一個介于 1 和 8,000 之間的數值
nvarchar(n) -- 長度可變 Unicode 字符數據 n 的值必須介于 1 與 4,000 之間,字節的存儲大小是所輸入字符個數的兩倍。
substring(exPRession,start,length) 從start開始截取length長度的字符串,下標從1開始select substring(Sname,0,1) as '從0開始取1個字符',substring(Sname,1,1) '從1開始取1個字符',* from Student
select left(Sname,1) '從左邊開始取1個字符',right(Sname,1) as '從右邊開始取1個字符',* from Student
print len(' 1234 5678 ') print datalength(' 1234 5678 ')
print charindex('4',' 1234 5678 ')
print replace(' 1234 5678 ','4','四')
print replace(' 1234 5678 ','4','四') print stuff(' 1234 5678 ',charindex('4',' 1234 5678 '),1,'四')
print upper(' abCDEf ') print lower(' abCDEf ') print ltrim(' abCDEf ') print rtrim(' abCDEf ')
select * from Studentselect * from Studentwhere S# between 1 and 3select * from Studentwhere Sage between '1989-01-01' and '1990-05-20'
select * from Studentselect * from Student where S# in(01,02) or Sname in('王菊','鄭竹')
select * from Studentselect * from Student where Sname like '%云' or Sname like '趙_'
select case year(Sage) when '1989' then '89年' when '1990' then '90年' when '1991' then '91年' else '不計算' end as '年份',* from Student select case when year(Sage)='1989' then '89年' when year(Sage)='1990' then '90年' when year(Sage)='1991' then '91年' else '不計算' end as '年份',* from Student
新聞熱點
疑難解答