34,838
社区成员




--------------------------------------
select name+','
from syscolumns
where id=object_id('TB_TEMPLOADING')
--------------------------------------
BRANCHCD,
EMPLOYEECD,
HTIP,
L_LBLCD,
TruckCD,
TRUCKLBL,
WAREHOUSECD,
(7 件処理されました)
select name
from syscolumns
where id=object_id('TB_TEMPLOADING')
name -------------------------------------------------------------
BRANCHCD
EMPLOYEECD
HTIP
L_LBLCD
TruckCD
TRUCKLBL
WAREHOUSECD
(7 件処理されました)
--------------------------------------
select name+','
from syscolumns
where id=object_id('TB_TEMPLOADING')
--------------------------------------
BRANCHCD,
EMPLOYEECD,
HTIP,
L_LBLCD,
TruckCD,
TRUCKLBL,
WAREHOUSECD,
(7 件処理されました)
--引自:昨夜小楼(Limpire )
--如何删除数组中的元素 续(6六楼问题)
create table #T (ID int,字段A varchar(100))
insert into #T
select 1,'10,13,13,13,13,23,33' union all
select 2,'11,132,13' union all
select 3,'13,15,138'
select * from #T
--先消灭中间的(根据实际数据特点,再做细分处理)
while exists (select 1 from #T where charindex(',13,',字段A) > 0)
update #T set 字段A = replace(字段A, ',13,', ',') where charindex(',13,', 字段A) > 0
select * from #T
--去尾
update #T set 字段A = left(字段A, len(字段A) - 3) where right(字段A, 3) = ',13'
select * from #T
--斩头
update #T set 字段A = right(字段A, len(字段A) - 3) where left(字段A, 3) = '13,'
select * from #T
drop table #T
--引自:昨夜小楼(Limpire )
-- 数据表如下
-- ID 字段A
-- 1 10,13,23,33
-- 2 11,12,13
-- 3 13,15,18
--
-- 要删除所有条记录字段A中的13
--
-- 得出如下结果.
-- ID 字段A
-- 1 10,23,33
-- 2 11,12
-- 3 15,18
--> 测试数据: #T
if object_id('tempdb.dbo.#T') is not null drop table #T
create table #T (ID int,字段A varchar(100))
insert into #T
select 1,'10,13,23,33' union all
select 2,'11,12,13' union all
select 3,'13,15,18'
select * from #T
--先消灭中间的
update #T set 字段A = replace(字段A, ',13,', ',') where charindex(',13,',字段A)>0
select * from #T
--去尾
update #T set 字段A = left(字段A, len(字段A) - 3) where right(字段A, 3) = ',13'
select * from #T
--斩头
update #T set 字段A = right(字段A, len(字段A) - 3) where left(字段A, 3) = '13,'
select * from #T
(3 件処理されました)
ID 字段A
----------- ----------------------------------------------------------------------------------------------------
1 10,13,23,33
2 11,12,13
3 13,15,18
(3 件処理されました)
(1 件処理されました)
ID 字段A
----------- ----------------------------------------------------------------------------------------------------
1 10,23,33
2 11,12,13
3 13,15,18
(3 件処理されました)
(1 件処理されました)
ID 字段A
----------- ----------------------------------------------------------------------------------------------------
1 10,23,33
2 11,12
3 13,15,18
(3 件処理されました)
(1 件処理されました)
ID 字段A
----------- ----------------------------------------------------------------------------------------------------
1 10,23,33
2 11,12
3 15,18
(3 件処理されました)