文章列表
 
您正在查看 "Sql Server" 分类下的文章

2008-12-18 21:11

 
2008-12-17 21:45

可以用select 给变量赋值

    create trigger tri_delete
            on jobs
            for delete
            as
                declare @job_id smallint
   

 
2008-11-22 14:36

create procedure pro_person15 @personID int,
@Quantity int output
as
declare @ErrerSave int
set @ErrerSave=0
--执行Select语句
select * from employees
where 人员编号=@personID
--保存任何非0的@@error值
if(@@error<>0)
set @ErrerSave=@@error
--输出参数
select @Quantity=max(Quantity) from [order details]
if(@@error<>0)
set @ErrerSave=@@Error
--如果所有的Select 语句执行正确,则返回0,否

 
2008-11-22 10:08
fetch next from abc into @a,@b

取到值后,定义两个临时变量@i,@j,保存@a、@b的值

修改@a、@b的值后,用Update语句更新回数据库

如:
update 表名 set 字段1=@a,字段2=@b where 字段1=@i and 字段2=@j

--------------------------------------------
定义一个变量,每循环一次加一
decalre @i int
set @i=0
while (@@fetch_status=0)
begin
...
set @i=@i+1
end
-------------------------------------------
DECLARE CURSOR
D
 
2008-11-22 10:00
字号:
 
2008-08-31 15:38

在学生成绩信息表中 判断学生的信息
如果成绩大于60分 则输出 及格
如果不大于60分 则输出 不及格

use ms
select id, case when id>60 then '及格'
else '不及格'
end
from owen

select id, 看清楚这里的逗号 一个逗号害死人

 
2008-08-19 12:10
select top 10 * from A where id not in (select top 5 id from A)
 
2008-07-24 21:48


create trigger t_test1 on employee
for update
as
set
nocount on
declare @division_id int,
@emp_id int
select @division_id=inserted.division_id,
      @emp_id=inserted.emp_id
from inserted

if(columns_updated()&16)>0
begin
print"division column reviewed in t_text1,id="+convert(char(2),@division_id)
end
if @division_id=2
begin
print "t_text1:division=2"
prin

 
2008-07-24 20:54
通过SET NOCOUNT ON 命令使触发器具有更好的性能

提交时
 
2008-07-24 20:42

Print Left ('张三',1)是什么意思

Print Left ('张三',1)

结果是显示 '张'

 
 
   
 
 
文章存档
 
     
 
最新文章评论
  

非常感谢楼主分享,受益了
 

谢谢分享
 

相当牛逼
 

谢谢,很实用
 

路过踩踩,小鸟
   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu