How the JSP invokes the MSSQL stored procedure (1/2)

Source: Internet
Author: User
Tags datetime mssql

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

Home 1 2 last page
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.