nick轩

导航

2010年11月23日 #

SQL 遍历所有表

摘要: ALTER proc Full_Search(@string varchar(50)) as begin declare @tbname varchar(50) declare tbroy cursor for select name from sysobjects where xtype= 'u ' --第一个游标遍历所有的表 open tbroy fetch next from tbroy i... 阅读全文

posted @ 2010-11-23 18:44 nick轩 阅读(1270) 评论(0) 推荐(0) 编辑

SQL 多表联合更新

摘要: 1、update a set a.p2=b.p2,a.bztks=b.bztks from Product a,price b where a.hpbm=b.hpbm2、update Product set Product.p2=price.p2 From Product,price WHERE Product.hpbm=price.hpbm 阅读全文

posted @ 2010-11-23 17:46 nick轩 阅读(356) 评论(0) 推荐(0) 编辑

如何把 SQL Server 的自增标志列清零

摘要: dbcc checkident(test1, reseed, 0)其中 test1 是表名称。事实上可以将标志的当前值设定到任意的值。下一次插入得值将会是这个当前值 + 1.比如:dbcc checkident(test1, reseed, 10)insert into test1 (name) values('zhangsan')得到的新纪录的 id 是 11.如果重设得值会导致插入后产生重复也... 阅读全文

posted @ 2010-11-23 17:45 nick轩 阅读(196) 评论(0) 推荐(1) 编辑

SQL 日期相关

摘要: select datepart(weekday,getdate()) 得到今天星期几select datepart(week,getdate()) 得到这周是第几周 阅读全文

posted @ 2010-11-23 17:45 nick轩 阅读(102) 评论(0) 推荐(0) 编辑