create function str_split(@c varchar(2000),@split varchar(2))
returns @t table(col varchar(20))
as
begin
while(charindex(@split,@c)<>0)
begin
insert @t(col) values (substring(@c,1,charindex(@split,@c)-1))
set @c = stuff(@c,1,charindex(@split,@c),'')
end
insert @t(col) values (@c)
return
end
go
declare @sql varchar(1000)
set @sql=''
select @sql=@sql+'
select '''+col+'''
union '
from (select col from dbo.str_split('北京,上海,廣州,天津,杭州,哈爾濱,廈門',',')) as e
print(left(@sql,len(@sql)-5))
sql判斷字串包含字串語句
在sql中我判斷包含字串我們可使用很多方法,如like,replace,charindex函式都可實現我們要的功能,下面我來給各位介紹判斷字串包含字串sql語句。如果想從sql server中查詢包含某個關鍵字的東東,怎麼查詢呢?一般有兩個方法 1.用like 如下 複製 select from t...
ORACLE in 字串,字串,字串
因為傳進來的引數是 字串,字串,字串,要實現in 字串,字串,字串 select from htl price p where p.hotel id 30073328 and p.able sale date between to date 2009 03 27 yyyy mm dd and to ...
sql 語句 exec 執行字串
create procedure dbo alldnn newspublish deletearticlebyarticle articleid nvarchar 200 as declare sql nvarchar 1000 set sql delete dbo.site news articl...