本文章来告诉你jsp教程如何调用mssql 存储过程吧,其实调用mssql的存储过程很简单的,下面我们先来创建表:
create table [bookuser] (
[userid] [int] identity (1, 1) not null ,
[username] [varchar] (50) collate chinese_prc_ci_as not null ,
[title] [nvarchar] (50) collate chinese_prc_ci_as not null ,
[guid] [uniqueidentifier] not null constraint [df_bookuser_guid] default (newid()),
[birthdate] [datetime] not null ,
[description] [ntext] collate chinese_prc_ci_as not null ,
[photo] [image] null ,
[other] [varchar] (50) collate chinese_prc_ci_as null
constraint [df_bookuser_other] default ('默认值'),
constraint [pk_bookuser] primary key clustered
(
[userid]
) on [primary]
) on [primary] textimage_on [primary]
go
创建存储过程:
create procedure insertuser
@username varchar(50),
@title varchar(255),
@guid uniqueidentifier,
@birthdate datetime,
@description ntext,
@photo image,
@other nvarchar(50),
@userid int output
as
set nocount on
if exists (select userid from bookuser where username = @username)
return 0
else
begin
insert into bookuser (username,title,guid,birthdate,description,photo,other)
values(@username,@title,@guid,@birthdate,@description,@photo,@other)
set @userid = @@identity
return 1
end
go
首页 1 2 末页