Fork me on GitHub
.net求学者

随笔分类 -  SQL Server

SQL Server
摘要:--拆分的方法有很多,临时表.SUBSTRING ...但都不如XML来得清凉爽快declare @tempstr varchar(500)set @tempstr='54,57,55,56,59'declare @Xmlstr xmlset @Xmlstr=Co nVERT(xml,'' + REPLACE(@tempstr, ',', '') + '') SELECT ids=N.v.value('.', 'int') FROM @Xmlstr.nodes('/root/ 阅读全文
posted @ 2014-01-16 11:02 hy31337 阅读(427) 评论(0) 推荐(0)
摘要:set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgo-- =============================================-- Author: hy-- Create date: -- Description: 后台企业管理-- [P_V_EffectiveInfo_getTable] '',1,'','','','','','','','','','',-1, 阅读全文
posted @ 2014-01-16 11:00 hy31337 阅读(1008) 评论(0) 推荐(0)
摘要:SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO--DEClARE @str varchar(500)='a,b2,v5,d3,ew,2,3,dd'--select [dbo].[split](@str,',',8)CREATE FUNCTION [dbo].[split](@str nvarchar(4000),@code varchar(10),@no int ) RETURNS varchar(200)AS BEGINdeclare @intLen intdeclare @count intdeclare @ind 阅读全文
posted @ 2014-01-16 10:52 hy31337 阅读(411) 评论(0) 推荐(0)
摘要:SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE function [dbo].[fun_getPY](@str nvarchar(4000))returns nvarchar(4000)asbegindeclare @word nchar(1),@PY nvarchar(4000)set @PY=''while len(@str)>0beginset @word=left(@str,1)--如果非汉字字符,返回原字符set @PY=@PY+(case when unicode(@word) between 19968 阅读全文
posted @ 2014-01-16 10:47 hy31337 阅读(602) 评论(0) 推荐(0)
摘要:SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE function [dbo].[fnQueryCharCountFromString](@str varchar(8000),@sub varchar(50))returns intasbegin declare @pos int,@n int select @n=0, @pos=charindex(@sub,@str) while(@pos0) begin select @str=right(@str,len(@str)-@pos),@pos=char... 阅读全文
posted @ 2014-01-16 10:15 hy31337 阅读(213) 评论(0) 推荐(0)

.net求学者