摘要: 随机数可以通过程序生成,也可以通过SQL语句生成。通过程序生成随机数时一般采用硬件的编号+时间作为种子,这种方法在瞬间插入数据库N条数据的时候会影响随机数的效果,生成很多相邻的插入值相同。所以频繁插入时可以使用SQL语句的内置函数生成随机数,可以避免此类事情发生。Demo:====================================================================================C#: int min=0,max=10; Random random = new Random(); int newNumber = random.Nex. 阅读全文
posted @ 2013-04-26 16:41 代岳强 阅读(2357) 评论(0) 推荐(0) 编辑
摘要: alter proc spFind_Column_In_DB ( @type int,--类型:1为文字类型、2为数值类型 @str nvarchar(100)--需要搜索的名字 ) as --创建临时表存放结果 create table #tbl(PK int identity primary key ,tbl sysname,col sysname) declare @tbl nvarchar(300),@col sysname,@sql nvarchar(1000) if @type=1 begin declare curTable cursor fast_forward ... 阅读全文
posted @ 2013-04-26 16:09 代岳强 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 建立正则替换函数,利用了OLE对象,以下是函数代码:[c-sharp] view plaincopyprint?IF OBJECT_ID(N'dbo.RegexReplace') IS NOT NULL DROP FUNCTION dbo.RegexReplace GO CREATE FUNCTION dbo.RegexReplace ( @string VARCHAR(MAX), --被替换的字符串 @pattern VARCHAR(255), --替换模板 @replacestr VARCHAR(255), --替换后的字符串 @IgnoreCase INT = 0 --0 阅读全文
posted @ 2013-04-26 15:48 代岳强 阅读(5261) 评论(1) 推荐(0) 编辑