if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[libai_choice]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[libai_choice]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[libai_book]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[libai_book]
GO

CREATE TABLE [dbo].[libai_book] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[libai_name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[libai_title] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[libai_content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[libai_time] [smalldatetime] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE  proc libai_choice
@choice varchar (50)='select',
@uid int=1,
@libai_name varchar (50)='libai',
@libai_title varchar (100)='libai',
@libai_content varchar (3000) ='ok'
as
if @choice='select'
select * from libai_book order by libai_time desc
if @choice='del'
delete from libai_book where id=@uid
if @choice='add'
insert into libai_book(libai_name,libai_title,libai_content)values(@libai_name,@libai_title,@libai_content)


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

