SQLSERVER快速構造測試資料
//建立一個表;
create table aa(id nvarchar(255),name nvarchar(255),description nvarchar(255))
go
//定義儲存過程
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE ID = OBJECT_ID(N'[dbo].[aaInsertProc]') and OBJECTPROPERTY(ID, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[aaInsertProc]
GO
create proc aaInsertProc
as //此處 as 不可以省略不寫
begin //begin 和 end 是一對,不可以只寫其中一個,但可以都不寫
declare @a int
declare @sum int
set @a=1
set @sum=0
while @a<=100
begin
set @
set @a+=1
print @a
insert into dbo.aa values ('11','22','33')
end
print @sum
end
go
//呼叫儲存過程
aaInsertProc
go
//檢視執行結果:
use xx
go
select count(*) as 'aa tran log length' from sys.fn_dblog(NULL,NULL) where AllocUnitName = 'dbo.aa'
go
select count(*) as 'aa table length' from aa
go