--------------------SQL Server数据格式化工具------------------- --------------------------------------------------------------- -- DESIGNER :happycell188(喜喜) -- QQ :584738179 -- Development Tool :Microsoft Visual C++ 6.0 C Language -- FUNCTION :CONVERT DATA TO T-SQL --------------------------------------------------------------- -- Microsoft SQL Server 2005 -- Developer Edition on Microsoft Windows XP [版本 5.1.2600] --------------------------------------------------------------- ---------------------------------------------------------------use test go if object_id('test.dbo.tb') is not null drop table tb -- 创建数据表 create table tb ( id int, value char(15) ) go --插入测试数据 insert into tb select 1,'001,002,1001,' union all select 2,'002,1001,' go --代码实现 select * from tb where charindex(',001,',','+value)>0 /*测试结果id value --------------------- 1 001,002,1001,(1 行受影响) */
where charindex(',001,',','+col+',')>0
where charindex(',001,',','+col+',')>0
--------------------SQL Server数据格式化工具-------------------
---------------------------------------------------------------
-- DESIGNER :happycell188(喜喜)
-- QQ :584738179
-- Development Tool :Microsoft Visual C++ 6.0 C Language
-- FUNCTION :CONVERT DATA TO T-SQL
---------------------------------------------------------------
-- Microsoft SQL Server 2005
-- Developer Edition on Microsoft Windows XP [版本 5.1.2600]
---------------------------------------------------------------
---------------------------------------------------------------use test
go
if object_id('test.dbo.tb') is not null drop table tb
-- 创建数据表
create table tb
(
id int,
value char(15)
)
go
--插入测试数据
insert into tb select 1,'001,002,1001,'
union all select 2,'002,1001,'
go
--代码实现
select * from tb where charindex(',001,',','+value)>0
/*测试结果id value
---------------------
1 001,002,1001,(1 行受影响)
*/