關於SQL更新stored procedure儲存過程

2022-06-05 09:05:03 字數 2322 閱讀 1520

1樓:匿名使用者

alter procedure proc_name

@value varchar(10)

as declare @tempvalue as varchar(10)

declare @temptable as table (number varchar(20))

begin

set @tempvalue = @value + cast((year(getdate( ))+1) as char(4))

insert into @temptable (number) values (@tempvalue)

select * from @temptable

end-- 原來的儲存過程是取當前年份來做處理的,所以year(getdate())+1就是2012了

2樓:匿名使用者

create procedure proc_name

@value varchar(10)

as declare @tempvalue as varchar(10)

declare @temptable as table (number varchar(20))

begin

set @tempvalue = @value + cast(year(dateadd(yyyy,1,getdate( ))) as char(4))

insert into @temptable (number) values (@tempvalue)

select * from @temptableend

3樓:一邊一半

set @tempvalue = @value + cast(year(getdate())+1 as char(4))

sql更新資料儲存過程怎麼寫

4樓:匿名使用者

create or replace procedure ***

如何在儲存過程中實現插入更新資料

在sql中儲存過程的一般語法是什麼?

5樓:次次次蛋黃公尺亞

1、 建立語法

create proc | procedure pro_name

[ [=預設值] [output],

[=預設值] [output],

....]as

sql_statements

2、 建立不帶引數儲存過程

--建立儲存過程

if (exists (select * from sys.objects where name = 'proc_get_student'))

drop proc proc_get_student

gocreate proc proc_get_student

asselect * from student;

--呼叫、執行儲存過程

exec proc_get_student;

3、 修改儲存過程

--修改儲存過程

alter proc proc_get_student

asselect * from student;

4、 帶參儲存過程

--帶參儲存過程

if (object_id('proc_find_stu', 'p') is not null)

drop proc proc_find_stu

gocreate proc proc_find_stu(@startid int, @endid int)

asselect * from student where id between @startid and @endid

goexec proc_find_stu 2, 4;

5、 帶萬用字元引數儲存過程

--帶萬用字元引數儲存過程

if (object_id('proc_findstudentbyname', 'p') is not null)

drop proc proc_findstudentbyname

gocreate proc proc_findstudentbyname(@name varchar(20) = '%j%', @nextname varchar(20) = '%')

asselect * from student where name like @name and name like @nextname;

goexec proc_findstudentbyname;exec proc_findstudentbyname '%o%', 't%';

sql語句,儲存過程,智慧型更新,SQL 乙個儲存過程中 執行兩個更新操作 怎麼寫

簡單啊,用if判定一下就可以了啊,在update之前先判定name是否為空 if isnull name,update 表 set username username where id id 同等道理,age也一樣的做就可以了。當然,判定條件並列的話,你可以一起判定 如果想使用多條語句的話,有兩種方...

如何實現MyBatis僅更新SQL語句中指定的字段

改成下面這樣即可。資料表 create table qai entity id char 10 not null,value int not null default 0,cre tim timestamp not null default current timestamp,primary key...

如何實現MyBatis僅更新SQL語句中指定的字段

物件 public class entity 如何實現mybatis僅更新sql語句中指定的字段 物件 public class entity 資料 表 create table qai entity id char 10 not null,value int not null defa 如何實現m...