
数据库技术
zjsunshine
媒体
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
SQLServer技巧集
1.把某个字段重新生气序列(从1到n):DECLARE @i intSet @i = 0Update Table1 Set @i = @i + 1,Field1 = @i2.按成绩排名次Update 成绩表Set a.名次 = (Select Count(*) + 1From 成绩表 bWhere a.总成绩 )From 成绩表 a3.查询外部数据库Select a.*From OpenR转载 2007-01-16 13:29:00 · 410 阅读 · 0 评论 -
asp.net使用access存储过程时报标准表达式中数据类型不匹配
1.时间类型需要用"#"括起来如 "#2010-8-25#2.程序后台paramenters添加参数需要与存储过程的参数顺序一致。如 access中 insert into (uid,btime,content) values(@uid,@btime,@content)则后台代码中cmd.parameters.add的顺序得是uid,btime,content原创 2010-08-25 14:24:00 · 539 阅读 · 0 评论 -
判断以,分隔的变量@picclassids是否存在于有以,分隔的字段的值
@picclassids 以,分隔的字符串变量如"1,2,3"piclassids 存储以,分隔的字符串字段,如"3,4,5"以下sql判断picclassids字段中是否存在@picclassids中的任何一个值 select * from t_pic where exists(select * from fn_split(picclassids,,) where a in (sel原创 2010-02-04 20:54:00 · 271 阅读 · 0 评论 -
数据库中随机取行
select top 1 * from photos order by newid()转载 2008-11-25 01:42:00 · 215 阅读 · 0 评论 -
合并表记录
select col1,col2 from t1 union all select col1,col2 from t2原创 2008-11-17 03:12:00 · 245 阅读 · 0 评论 -
创建用户自定义函数
//创建用户自定义函数------标量函数 create function dbo.bmrs(@bmh as int)returns intasbegindeclare @bmrs intselect @bmrs=count(工号) from 销售人员 where 部门号=@bmhreturn @bmrsendgoexec sp_h转载 2008-11-13 22:40:00 · 403 阅读 · 0 评论 -
SQLServer : EXEC和sp_executesql的区别
<!--google_ad_client = "pub-5186257027655535";/* 728x90, 创建于 08-9-16 */google_ad_slot = "8128559615";google_ad_width = 728;google_ad_height = 90;//--><script type="text/javascript"sr转载 2008-11-13 22:20:00 · 350 阅读 · 1 评论 -
轻松掌握设计 Sql Server触发器的原理
触发器 1、触发器的 本质: 触发器是一种特殊的存储过程,它不能被显式地调用, 而是在往表中插入记录、更改记录或者删除记录时,当事件发生时,才被 自动地激活。 2、这样做带来的 功能: 触发器可以用来对表实施复杂的完整性约束,保持数 据的一致性,当触发器所保护的数据发生改变时,触发器会自动被激活, 响应同时执行一定的操作(对其它相关表转载 2008-10-20 15:48:00 · 301 阅读 · 0 评论 -
ms sql全局变量
SQL全局变量 select APP_NAME ( ) as w --当前会话的应用程序 select @@ERROR --返回最后执行的 Transact-SQL 语句的错误代码(integer) select @@IDENTITY --返回最后插入的标识值 select USER_NAME() --返回用户数据库用户名 select @@CONNECTION原创 2008-10-20 15:40:00 · 681 阅读 · 0 评论 -
存储过程获取子分类id
<!--google_ad_client = "pub-5186257027655535";/* 728x90, 创建于 08-9-16 */google_ad_slot = "8128559615";google_ad_width = 728;google_ad_height = 90;//--><script type="text/javascript"sr原创 2008-09-21 03:22:00 · 345 阅读 · 0 评论 -
简单SQL语句小结
为了大家更容易理解我举出的SQL语句,本文假定已经建立了一个学生成绩管理数据库,全文均以学生成绩的管理为例来描述。 1.在查询结果中显示列名: a.用as关键字:select name as 姓名 from students order by age b.直接表示:select name 姓名 from students order by age 2.精确查找:转载 2007-04-17 12:54:00 · 361 阅读 · 0 评论 -
sql case when用法
当用来判断null字段时 只能用case when 字段 is null then 0 end 而不能以case 字段 when null then 0 end来用。原创 2012-06-05 19:29:37 · 229 阅读 · 0 评论