ALTER function [dbo].[Zfun_bage](@UDF02 char(40)) returns int as --把包装方法自动计算成件数 BEGIN declare @A CHAR(20) declare @num int select top 1 @A=UDF02 from COPTH WHERE UDF02=@UDF02 if (CHARINDEX
一、测试环境: 1。数据库:Sql Server 2008 2。测试表:15000记录,char类型主键,无其他索引 3。测试字段:ntext 类型,最大数据长度12000 二、测试语句: 1。select * from ProductTemp where ProductDesc like ‘%192.168.70.236%’ 2。select * from ProductTemp w
需要从表中取出如id in(148,153,149,156)符合条件的记录,需要保持取出记录仍按(148,153,149,156)顺序排列。 用到CHARINDEX函数 WHERE [id] in (148,153,149,156) ORDER BY CHARINDEX(','+CAST([Id] as varchar)+',',','+'148,153,149,156'+',') 相当于