需求:实际项目中需要截取第2到第3个逗号中间部分的内容 方案: declare @str nvarchar(50);set @str='11,222,3333,44444';select @str as '字符串'select len(@str) as '字符长度'select charindex(',',@str,1) as '第一个逗号的索引值'select LEFT(@str,charindex(',',@str,1)-1) as '第一个值'select SUBSTRING(@str,c
以前拼接的写法 set @sql=' select * from table where 1=1 ' if (@addDate is not null) set @sql = @sql+' and addDate = '+ @addDate + ' ' if (@name <>'' and is not null) set @sql = @sql+ ' and name = ' + @name + ' ' exec(@sql) 下面是 不采用拼接SQL字符串实现多条件查询的解决方案 第
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA SQL字符串连接操作 前言部分 大家可以关注我的公众号,公众号里的排版更好,阅读更舒适. 正文部分 把多个字符串连接起来,在HANA SQL里这样写 关键字:concat )) as begin declare cursor C for SELECT OITM.”ItemName” from OITM;
SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO --功能:分拆字符串 --参数:@String:要分拆的字符串:@Delimiter:分割符号 --返回值:@ValueTable结果表 create FUNCTION dbo.fn_Split( ), ) ) ),[id] int) BEGIN ), @Pos int, @NextPos int, ), @id int SET @NextString = '' ) SET @String = @Stri