jsp如何調用mssql 預存程序(1/2)

來源:互聯網
上載者:User

本文章來告訴你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 末頁
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.