sql

1.query all the store procedures in the specfied db;

use MyDB
select * from INFORMATION_SCHEMA.ROUTINES  where ROUTINE_TYPE='procedure'

 2.create proc with while loop

create proc BatchInsertYearSalary
as 
declare @year int
declare @nowYear int
declare @salary money
begin
set @year=2011
set @nowYear=YEAR(GETDATE())
set @salary=10
while(@year<=@nowYear)
begin
insert into dbo.YearSalary
values(@year,@salary);
set @year=@year+1
set @salary=@salary+10
end
end

 

posted @ 2019-09-08 15:31  FredGrit  阅读(193)  评论(0编辑  收藏  举报