This article tells you how the JSP tutorial calls the MSSQL stored procedure , in fact invokes the MSSQL stored procedure very simply, let's start by creating the table:
CREATE TABLE [Bookuser] (
[UserID] [INT] Identity (1, 1) NOT NULL,
[Username] [varchar] (m) collate chinese_prc_ci_as NOT NULL,
[Title] [nvarchar] (m) 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] (m) Collate chinese_prc_ci_as NULL
constraint [Df_bookuser_other] Default (' Default value '),
constraint [Pk_bookuser] primary key clustered
(
[UserID]
) on [primary]
) on [primary] textimage_on [primary]
Go
To 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