This article tells you how to call the mssql Stored Procedure in jsp. In fact, the stored procedure of calling mssql is very simple. Let's create a table first:
This article will show you how to call the jsp tutorialMssql Stored ProcedureActuallyCall the stored procedure of mssqlIt's easy. Let's create a table first:
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 ('default '),
Constraint [pk_bookuser] primary key clustered
(
[Userid]
) On [primary]
) On [primary] textimage_on [primary]
Go
Create a stored procedure:
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