2013年12月19日

七.生成n位随机字符串

摘要: --1、借助newid()go--创建视图(因为在函数中无法直接使用newid())create view vnewidasselect newid() N'MacoId';go--创建函数create function getrandstr(@n int)returns varchar(max)asbegin declare @i int set @i=ceiling(@n/32.00) declare @j int set @j=0 declare @k varchar(max) set @k='' while @j=48 and @number=... 阅读全文

posted @ 2013-12-19 14:45 Dralion 阅读(247) 评论(0) 推荐(0)

六.求两个字符串中相同的汉字及字母的个数

摘要: --创建函数create function [dbo].[funcomparestring]( @stra nvarchar(200), @strb nvarchar(200))returns int asbegin declare @strbase nvarchar(200) declare @rank int select @rank=0 if len(@stra)>len(@strb) select @rank=count(*) from funsplitchar(@strb) w... 阅读全文

posted @ 2013-12-19 14:45 Dralion 阅读(264) 评论(0) 推荐(0)

五.将十进制转成十六进制

摘要: --创建函数create function [dbo].[hex](@cardno int )returns varchar (100)asbegin declare @temp_mod int declare @i int declare @result varchar(100) declare @temp_x int declare @result_values int set @result='' set @i=1 set @temp_x=0while @cardno>0 begin set @tem... 阅读全文

posted @ 2013-12-19 10:18 Dralion 阅读(193) 评论(0) 推荐(0)

四.综合模糊查询

摘要: --创建函数create function [dbo].[m_fuzzyquery_v1]( @str nvarchar(2000)) returns nvarchar(2000)as begin declare @count int,@i int; declare @newchar nvarchar(200),@nn nvarchar(300),@hh nvarchar(200) set @count=len(@str);set @i=1;set @nn=''; while @i<@count+1 begin ... 阅读全文

posted @ 2013-12-19 10:17 Dralion 阅读(179) 评论(0) 推荐(0)

三.求第一个字符串中第二个串的个数

摘要: --创建函数create function [dbo].[m_count]( @str_one nvarchar(200), --第一个字符串 @str_two nvarchar(200) --第二个字符串)returns int asbegin declare @sqlcount int select @sqlcount=(len(@str_one)-len(replace(@str_one,@str_two,'')))/len(@str_two)return @sqlcountend --测试示例select dbo.m_count('sqlserver', 阅读全文

posted @ 2013-12-19 10:15 Dralion 阅读(184) 评论(0) 推荐(0)

二.去除字符串中连续的分割符

摘要: --创建函数create function [dbo].[m_delrepeatsplit]( @str varchar(2000), @split nvarchar(200))returns nvarchar(2000)as begin --begin declare declare @count int,@i int,@isnull int declare @newchar nvarchar(200),@nn nvarchar(300) set @count=len(@str);set @i=1;set @isnull=1;se... 阅读全文

posted @ 2013-12-19 10:11 Dralion 阅读(394) 评论(0) 推荐(0)

一.去除字符串中的html标记及标记中的内容

摘要: --1、创建函数create function [dbo].[clearhtml] (@maco varchar(8000))returns varchar(8000) as begin declare @i int while 1 = 1 begin set @i=len(@maco) set @maco=replace(@maco, substring(@maco,charindex('',@maco)-charindex('登录新闻网页贴吧知道MP3图片视频 帮助高级'select dbo.clearhtml (@mark)--3、运行结果/*n... 阅读全文

posted @ 2013-12-19 10:04 Dralion 阅读(313) 评论(0) 推荐(0)

导航