1
select seeds_casemaster.case_id as case_id,
(select top 1 seeds_module from seeds_queue_module,seeds_caseactivity where seeds_caseactivity.case_id=seeds_casemaster.case_id and patindex('%'+ rtrim(ltrim(seeds_queue))+'%',seeds_caseactivity.additional_info) <> 0 and seeds_caseactivity.activity like 'accept%' order by seeds_caseactivity.activity_time desc ) as seeds_module
into #a
from seeds_casemaster
update seeds_casemaster
set modulecode=#a.seeds_module
from #a,seeds_casemaster
where seeds_casemaster.case_id
=#a.case_id and isnull(#a.seeds_module,'0')<>'0'
drop table #a
2 set quoted_identifier on go
set ansi_nulls on go
alter procedure mrf_common_getemails_newregistration
@in_country as int as
declare @stremails as varchar(4000)
set @stremails = ''
select @stremails = case @stremails
when '' then [user].user_email
else @stremails + ';' + [user].[user_email]
endfrom mrf_country country
join mrf_user_region userregion on country.cntr_rgn_id = userregion.usrg_rgn_id
join mrf_user [user] on [user].[user_id] = userregion.usrg_user_id
where country.cntr_id = @in_country -- for regional admin
select @stremails = case @stremails
when '' then [user].user_email
else @stremails + ';' + [user].[user_email]
endfrom mrf_user_role userrole
join mrf_user [user] on [user].[user_id] = userrole.usrl_user_id
where userrole.usrl_role_id = 1 -- for global admin
select @stremails go
set quoted_identifier off go
set ansi_nulls on go
3複製表
(只複製結構
,源表名:
a 新錶名:
b)
select * into b from a where 1<>1 4
if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[s_case_closurereport]') and objectproperty(id, n'isprocedure') = 1)
5 if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[resolution_time_detail1]') and objectproperty(id, n'isusertable') = 1)
SQL語句很實用很巧妙的用法
1.ignore的用法 在insert 後面加上ignore之後,如果插入的資料有重複等問題時,失敗不會報錯,很實用的小技巧 insert ignore into success killed seckill id,user phone,state values 0 2.ifnull a,0 函式的...
特殊需求的sql
1.更新乙個表,但是這個表裡需要另乙個級聯表的關聯資料才能操作,這個常用於批量運算元據庫的時候會用到。可採用update table1,table2 set table1.name table2.name where table1.xx id table2.xx id 2.縱向字段橫向統計。upda...
我的問題很特殊。希望高手賜教!
if request.querystring no eshop then title request title content htmlencode2 request content if title then response.write sorry response.write 請輸入更新內容...