/* *参数说明: 第一个参数为要转化的字符串,第二个参数为字符串中间的分隔符 */ ),)) )) as begin ) set @SourceSql=@SourceSql+@StrSeprate while(@SourceSql<>'') begin )) insert @temp values(@ch) ,),'') end return end 使用场景为 需要拼接字符串与其他select结果作为in条件的时候使用 或者是其他用途 使用方法示例:
以前拼接的写法 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字符串实现多条件查询的解决方案 第
root@hett-virtual-machine:~# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \ --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutronNo handlers could be found for logger "oslo_config.cfg"
--将给定的逗号分隔的数字字符串转换为Table CREATE FUNCTION [dbo].[fu_Split](@strString nvarchar(4000)) RETURNS @Result TABLE(Value int) AS BEGIN DECLARE @x xml SELECT @x = CAST('<A>' + REPLACE(@strString,',','</A><A>') + '</A>' AS xml) INSERT INTO @