根據以上的代碼生成的表,自動生成的簡單的添加、刪除、修改、查詢的存儲過程(關聯還沒有考慮,可以考慮進去) 自動生成實體(老版的)未考慮預設值 ...
---搖獎observeh資料庫設計 Function getSpace lottery /* -- Author:geovindu 塗聚文 -- Date: 20180427 為了自寫生成代碼。根據Metedata 生成有註釋和關係表的代碼,表必須要主鍵和註釋 CREATE DATABASE LotteryDrawing GO USE LotteryDrawing GO */ ---獎項項目表AwardProject IF EXISTS (select * from sysobjects where id = object_id(N'dbo.AwardProject') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE AwardProject GO CREATE TABLE AwardProject ( ProjectId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, ProjectName NVARCHAR(300) NOT NULL, --項目名稱,顯示年度年會上 ProjectYear VARCHAR(20) NOT NULL, --年度名稱 ProjectDate DATETIME DEFAULT(GETDATE()) --創建日期 ) GO IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'AwardProject', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎項項目表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProject', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'項目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProject', @level2type=N'COLUMN',@level2name=N'ProjectId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'項目名稱,顯示年度年會上' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProject', @level2type=N'COLUMN',@level2name=N'ProjectName' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'年度名稱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProject', @level2type=N'COLUMN',@level2name=N'ProjectYear' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'創建日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProject', @level2type=N'COLUMN',@level2name=N'ProjectDate' GO SELECT * FROM dbo.AwardProject GO --抽獎員工表 Employee IF EXISTS (select * from sysobjects where id = object_id(N'dbo.Employee') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE Employee GO CREATE TABLE Employee ( EmployeeId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, EmployeeProjectId INT FOREIGN KEY REFERENCES AwardProject(ProjectId), --外鍵,項目ID EmployeeNO VARCHAR(30) NOT NULL, --員工編號 EmployeeName NVARCHAR(100) NOT NULL, --員工姓名 EmployeeMobile VARCHAR(20) NOT NULL, --手機號碼 --skype EmployeeDate DATETIME DEFAULT(GETDATE()) ) GO ---表描述 IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'TicketManage', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'抽獎員工表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Employee', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'員工ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Employee', @level2type=N'COLUMN',@level2name=N'EmployeeId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外鍵,項目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Employee', @level2type=N'COLUMN',@level2name=N'EmployeeProjectId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'員工編號' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Employee', @level2type=N'COLUMN',@level2name=N'EmployeeNO' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'員工姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Employee', @level2type=N'COLUMN',@level2name=N'EmployeeName' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手機號碼' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Employee', @level2type=N'COLUMN',@level2name=N'EmployeeMobile' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Employee', @level2type=N'COLUMN',@level2name=N'EmployeeDate' GO SELECT * FROM dbo.Employee GO --獎項表 AwardType IF EXISTS (select * from sysobjects where id = object_id(N'dbo.AwardType') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE AwardType GO CREATE TABLE AwardType ( AwardTypeId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, AwardProjectId INT FOREIGN KEY REFERENCES AwardProject(ProjectId), --外鍵,項目ID AwardName NVARCHAR(100) NOT NULL, --獎項名稱,如:特等獎,一等獎 AwardPersonNumber INT DEFAULT(1), --獎項人數 AwardVeryNumber INT DEFAULT(1), --每次抽的人數 AwardVeryProduct INT DEFAULT(1) --獎項每人產品數量 ) GO ---表描述 IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'TicketManage', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎項表 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardType', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎項ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardType', @level2type=N'COLUMN',@level2name=N'AwardTypeId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外鍵,項目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardType', @level2type=N'COLUMN',@level2name=N'AwardProjectId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎項名稱,如:特等獎,一等獎' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardType', @level2type=N'COLUMN',@level2name=N'AwardName' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎項人數' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardType', @level2type=N'COLUMN',@level2name=N'AwardPersonNumber' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'每次抽的人數' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardType', @level2type=N'COLUMN',@level2name=N'AwardVeryNumber' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎項每人產品數量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardType', @level2type=N'COLUMN',@level2name=N'AwardVeryProduct' GO SELECT * FROM dbo.AwardType GO --獎品表 AwardProduct IF EXISTS (select * from sysobjects where id = object_id(N'dbo.AwardProduct') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE AwardProduct GO CREATE TABLE AwardProduct ( ProductId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, ProductAwardTypeId INT FOREIGN KEY REFERENCES AwardType(AwardTypeId), --外鍵,獎項類型ID ProductName NVARCHAR(200) NOT NULL, --獎品名稱 ProductNo VARCHAR(50) NULL, --獎品編號(便於掃碼) ProductTotal INT NOT NULL --獎品數量 (總數量要和獎品人數*每個獎項數量相符,程式要驗證) ) GO ---表描述 IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'AwardProduct', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎品表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProduct', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProduct', @level2type=N'COLUMN',@level2name=N'ProductId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外鍵,獎項類型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProduct', @level2type=N'COLUMN',@level2name=N'ProductAwardTypeId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎品名稱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProduct', @level2type=N'COLUMN',@level2name=N'ProductName' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎品編號' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProduct', @level2type=N'COLUMN',@level2name=N'ProductNo' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎品數量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProduct', @level2type=N'COLUMN',@level2name=N'ProductTotal' GO SELECT * FROM dbo.AwardProduct GO --獎品圖片表 IF EXISTS (select * from sysobjects where id = object_id(N'dbo.AwardProductImage') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE AwardProductImage GO CREATE TABLE AwardProductImage ( ProductImageId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, ProductImageProductId INT FOREIGN KEY REFERENCES AwardProduct(ProductId), --外鍵,產品ID ProductImageByte IMAGE --產品圖片 ) GO ---表描述 IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'AwardProductImage', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獎品圖片表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProductImage', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'圖片ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProductImage', @level2type=N'COLUMN',@level2name=N'ProductImageId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外鍵,產品ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProductImage', @level2type=N'COLUMN',@level2name=N'ProductImageProductId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'產品圖片' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'AwardProductImage', @level2type=N'COLUMN',@level2name=N'ProductImageByte' GO SELECT * FROM dbo.AwardProductImage GO --獲獎者列表 LuckyWinner ---獎品確認收簽 IF EXISTS (select * from sysobjects where id = object_id(N'dbo.LuckyWinner') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE LuckyWinner GO CREATE TABLE LuckyWinner ( WinnerId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, WinnerEmployeeId INT FOREIGN KEY REFERENCES Employee(EmployeeId), --外鍵,員工ID WinnerAwardTypeId INT FOREIGN KEY REFERENCES AwardType(AwardTypeId), --外鍵,獎項類型ID WinnerIsOk BIT DEFAULT(0), --是否簽收確認 WinnerSinger NVARCHAR(50) NULL, --簽收人(或代理人) WinnerDate datetime NULL --確認簽收日期 ) GO ---表描述 IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'LuckyWinner', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獲獎者列表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'LuckyWinner', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'獲獎者ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'LuckyWinner', @level2type=N'COLUMN',@level2name=N'WinnerId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外鍵,員工ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'LuckyWinner', @level2type=N'COLUMN',@level2name=N'WinnerEmployeeId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外鍵,獎項類型ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'LuckyWinner', @level2type=N'COLUMN',@level2name=N'WinnerAwardTypeId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否簽收確認' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'LuckyWinner', @level2type=N'COLUMN',@level2name=N'WinnerIsOk' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'簽收人(或代理人)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'LuckyWinner', @level2type=N'COLUMN',@level2name=N'WinnerSinger' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'確認簽收日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'LuckyWinner', @level2type=N'COLUMN',@level2name=N'WinnerDate' GO SELECT * FROM dbo.LuckyWinner GO --所穫獎者發簡訊,SKYPE信息等 WinnerSms IF EXISTS (select * from sysobjects where id = object_id(N'dbo.WinnerSms') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE WinnerSms GO CREATE TABLE WinnerSms ( SmsId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, SmsEmployeeId INT FOREIGN KEY REFERENCES Employee(EmployeeId), --外鍵,員工ID SmsContent NVARCHAR(2000) NOT NULL, --簡訊內容 SmsDate DATETIME DEFAULT(GETDATE()) --發送時間 ) GO ---表描述 IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'WinnerSms', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所穫獎者發簡訊表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'WinnerSms', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'簡訊ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'WinnerSms', @level2type=N'COLUMN',@level2name=N'SmsId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外鍵,員工ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'WinnerSms', @level2type=N'COLUMN',@level2name=N'SmsEmployeeId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'簡訊內容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'WinnerSms', @level2type=N'COLUMN',@level2name=N'SmsContent' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'發送時間' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'WinnerSms', @level2type=N'COLUMN',@level2name=N'SmsDate' GO SELECT * FROM dbo.WinnerSms GO --視窗背景圖 IF EXISTS (select * from sysobjects where id = object_id(N'dbo.FormBackground') and OBJECTPROPERTY(id, N'IsUserTable') = 1) DROP TABLE FormBackground GO CREATE TABLE FormBackground ( BackgroundId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, BackgroundImage IMAGE, BackgroundFmName NVARCHAR(200) ) GO IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'FormBackground', null,null)) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'視窗背景圖表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FormBackground', @level2type=NULL,@level2name=NULL GO --列描述 EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FormBackground', @level2type=N'COLUMN',@level2name=N'BackgroundId' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'背景圖' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FormBackground', @level2type=N'COLUMN',@level2name=N'BackgroundImage' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'視窗名稱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FormBackground', @level2type=N'COLUMN',@level2name=N'BackgroundFmName' GO SELECT * FROM dbo.FormBackground
根據以上的代碼生成的表,自動生成的簡單的添加、刪除、修改、查詢的存儲過程(關聯還沒有考慮,可以考慮進去)
IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_AwardProject') DROP PROCEDURE dbo.proc_Insert_AwardProject GO CREATE PROCEDURE dbo.proc_Insert_AwardProject ( @ProjectName NVarChar(600), @ProjectYear VarChar(20), @ProjectDate DateTime ) AS INSERT INTO dbo.AwardProject ( [ProjectName] , [ProjectYear] , [ProjectDate] ) VALUES ( @ProjectName , @ProjectYear , @ProjectDate ) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表增加記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '項目名稱,顯示年度年會上', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', N'parameter', N'@ProjectName' GO EXECUTE sp_addextendedproperty N'MS_Description', '年度名稱', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', N'parameter', N'@ProjectYear' GO EXECUTE sp_addextendedproperty N'MS_Description', '創建日期', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', N'parameter', N'@ProjectDate' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_AwardProjectOutput') DROP PROCEDURE dbo.proc_Insert_AwardProjectOutput GO CREATE PROCEDURE dbo.proc_Insert_AwardProjectOutput ( @ProjectName NVarChar(600), @ProjectYear VarChar(20), @ProjectDate DateTime, @ProjectId int output ) AS INSERT INTO dbo.AwardProject ( [ProjectName] , [ProjectYear] , [ProjectDate] ) VALUES ( @ProjectName , @ProjectYear , @ProjectDate ) select @ProjectId=@@IDENTITY GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表添加記錄有返回值的存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '項目名稱,顯示年度年會上', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', N'parameter', N'@ProjectName' GO EXECUTE sp_addextendedproperty N'MS_Description', '年度名稱', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', N'parameter', N'@ProjectYear' GO EXECUTE sp_addextendedproperty N'MS_Description', '創建日期', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', N'parameter', N'@ProjectDate' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵輸出', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProject', N'parameter', N'@ProjectId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_AwardProject') DROP PROCEDURE dbo.proc_Update_AwardProject GO CREATE PROCEDURE dbo.proc_Update_AwardProject ( @ProjectId Int, @ProjectName NVarChar(600), @ProjectYear VarChar(20), @ProjectDate DateTime ) AS UPDATE dbo.AwardProject SET [ProjectName]=@ProjectName , [ProjectYear]=@ProjectYear , [ProjectDate]=@ProjectDate where [ProjectId]=@ProjectId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表修改記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_AwardProject', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '項目名稱,顯示年度年會上', N'user', N'dbo', N'procedure', N'proc_Update_AwardProject', N'parameter', N'@ProjectName' GO EXECUTE sp_addextendedproperty N'MS_Description', '年度名稱', N'user', N'dbo', N'procedure', N'proc_Update_AwardProject', N'parameter', N'@ProjectYear' GO EXECUTE sp_addextendedproperty N'MS_Description', '創建日期', N'user', N'dbo', N'procedure', N'proc_Update_AwardProject', N'parameter', N'@ProjectDate' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵', N'user', N'dbo', N'procedure', N'proc_Update_AwardProject', N'parameter', N'@ProjectId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_AwardProjectField') DROP PROCEDURE dbo.proc_Update_AwardProjectField GO CREATE PROCEDURE dbo.proc_Update_AwardProjectField ( @ProjectId Int, @FieldValue NVARCHAR(1500) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='update dbo.AwardProject set '+@FieldValue+' WHERE ProjectId ='+ CAST(@ProjectId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表修改某一列數據的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_AwardProjectField', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表修改欄位名及其值如:[Remark]=A', N'user', N'dbo', N'procedure', N'proc_Update_AwardProjectField', N'parameter', N'@FieldValue' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵', N'user', N'dbo', N'procedure', N'proc_Update_AwardProjectField', N'parameter', N'@ProjectId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_AwardProject') DROP PROCEDURE dbo.proc_Delete_AwardProject GO CREATE PROCEDURE dbo.proc_Delete_AwardProject ( @ProjectId Int ) as DELETE dbo.AwardProject WHERE ProjectId = @ProjectId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表刪除記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProject', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProject', N'parameter', N'@ProjectId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_AwardProjectId') DROP PROCEDURE dbo.proc_Delete_AwardProjectId GO CREATE PROCEDURE dbo.proc_Delete_AwardProjectId ( @ProjectId varchar(2000) ) as DECLARE @strsql varchar(3000) SET @strsql='DELETE dbo.AwardProject WHERE ProjectId in('+@ProjectId+')' EXEC(@strsql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表刪除多條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProjectId', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProjectId', N'parameter', N'@ProjectId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProject') DROP PROCEDURE dbo.proc_Select_AwardProject GO CREATE PROCEDURE dbo.proc_Select_AwardProject ( @ProjectId Int ) AS SELECT * FROM dbo.AwardProject WHERE ProjectId = @ProjectId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProject', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardProject', N'parameter', N'@ProjectId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProjectExists') DROP PROCEDURE dbo.proc_Select_AwardProjectExists GO CREATE PROCEDURE dbo.proc_Select_AwardProjectExists ( @ProjectId Int ) AS SELECT count(1) as H FROM dbo.AwardProject WHERE ProjectId = @ProjectId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表是否存在某記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectExists', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectExists', N'parameter', N'@ProjectId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProjectCount') DROP PROCEDURE dbo.proc_Select_AwardProjectCount GO CREATE PROCEDURE dbo.proc_Select_AwardProjectCount ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.AwardProject ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectCount', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectCount', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProjectCountView') DROP PROCEDURE dbo.proc_Select_AwardProjectCountView GO CREATE PROCEDURE dbo.proc_Select_AwardProjectCountView ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.View_AwardProject ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表視圖查詢共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectCountView', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectCountView', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProjectTitle') DROP PROCEDURE dbo.proc_Select_AwardProjectTitle GO CREATE PROCEDURE dbo.proc_Select_AwardProjectTitle ( @FieldName NVARCHAR(100), @ProjectId Int ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select top 1 '+@FieldName+' from dbo.AwardProject WHERE ProjectId ='+ CAST(@ProjectId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表返回某欄位的標題記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectTitle', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectTitle', N'parameter', N'@FieldName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectTitle', N'parameter', N'@ProjectId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProjectFuzzySearch') DROP PROCEDURE dbo.proc_Select_AwardProjectFuzzySearch GO CREATE PROCEDURE dbo.proc_Select_AwardProjectFuzzySearch ( @FieldList NVARCHAR(1000), @where NVARCHAR(2000) ) AS DECLARE @sql NVARCHAR(4000) IF(@where<>'') SET @where=' WHERE '+@where IF(@FieldList='') SET @FieldList=' * ' SET @sql='select '+@FieldList+' from dbo.AwardProject '+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表模糊查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProject', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_AwardProject', N'parameter', N'@FieldList' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardProject', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProjectAll') DROP PROCEDURE dbo.proc_Select_AwardProjectAll GO CREATE PROCEDURE dbo.proc_Select_AwardProjectAll AS SELECT * FROM dbo.AwardProject GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項項目表查詢所有記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProjectAll', NULL, NULL GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_Employee') DROP PROCEDURE dbo.proc_Insert_Employee GO CREATE PROCEDURE dbo.proc_Insert_Employee ( @EmployeeProjectId Int, @EmployeeNO VarChar(30), @EmployeeName NVarChar(200), @EmployeeMobile VarChar(20), @EmployeeDate DateTime ) AS INSERT INTO dbo.Employee ( [EmployeeProjectId] , [EmployeeNO] , [EmployeeName] , [EmployeeMobile] , [EmployeeDate] ) VALUES ( @EmployeeProjectId , @EmployeeNO , @EmployeeName , @EmployeeMobile , @EmployeeDate ) GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表增加記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,項目ID', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeProjectId' GO EXECUTE sp_addextendedproperty N'MS_Description', '員工編號', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeNO' GO EXECUTE sp_addextendedproperty N'MS_Description', '員工姓名', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeName' GO EXECUTE sp_addextendedproperty N'MS_Description', '手機號碼', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeMobile' GO EXECUTE sp_addextendedproperty N'MS_Description', '日期', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeDate' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_EmployeeOutput') DROP PROCEDURE dbo.proc_Insert_EmployeeOutput GO CREATE PROCEDURE dbo.proc_Insert_EmployeeOutput ( @EmployeeProjectId Int, @EmployeeNO VarChar(30), @EmployeeName NVarChar(200), @EmployeeMobile VarChar(20), @EmployeeDate DateTime, @EmployeeId int output ) AS INSERT INTO dbo.Employee ( [EmployeeProjectId] , [EmployeeNO] , [EmployeeName] , [EmployeeMobile] , [EmployeeDate] ) VALUES ( @EmployeeProjectId , @EmployeeNO , @EmployeeName , @EmployeeMobile , @EmployeeDate ) select @EmployeeId=@@IDENTITY GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表添加記錄有返回值的存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,項目ID', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeProjectId' GO EXECUTE sp_addextendedproperty N'MS_Description', '員工編號', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeNO' GO EXECUTE sp_addextendedproperty N'MS_Description', '員工姓名', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeName' GO EXECUTE sp_addextendedproperty N'MS_Description', '手機號碼', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeMobile' GO EXECUTE sp_addextendedproperty N'MS_Description', '日期', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeDate' GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵輸出', N'user', N'dbo', N'procedure', N'proc_Insert_Employee', N'parameter', N'@EmployeeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_Employee') DROP PROCEDURE dbo.proc_Update_Employee GO CREATE PROCEDURE dbo.proc_Update_Employee ( @EmployeeId Int, @EmployeeProjectId Int, @EmployeeNO VarChar(30), @EmployeeName NVarChar(200), @EmployeeMobile VarChar(20), @EmployeeDate DateTime ) AS UPDATE dbo.Employee SET [EmployeeProjectId]=@EmployeeProjectId , [EmployeeNO]=@EmployeeNO , [EmployeeName]=@EmployeeName , [EmployeeMobile]=@EmployeeMobile , [EmployeeDate]=@EmployeeDate where [EmployeeId]=@EmployeeId GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表修改記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_Employee', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,項目ID', N'user', N'dbo', N'procedure', N'proc_Update_Employee', N'parameter', N'@EmployeeProjectId' GO EXECUTE sp_addextendedproperty N'MS_Description', '員工編號', N'user', N'dbo', N'procedure', N'proc_Update_Employee', N'parameter', N'@EmployeeNO' GO EXECUTE sp_addextendedproperty N'MS_Description', '員工姓名', N'user', N'dbo', N'procedure', N'proc_Update_Employee', N'parameter', N'@EmployeeName' GO EXECUTE sp_addextendedproperty N'MS_Description', '手機號碼', N'user', N'dbo', N'procedure', N'proc_Update_Employee', N'parameter', N'@EmployeeMobile' GO EXECUTE sp_addextendedproperty N'MS_Description', '日期', N'user', N'dbo', N'procedure', N'proc_Update_Employee', N'parameter', N'@EmployeeDate' GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵', N'user', N'dbo', N'procedure', N'proc_Update_Employee', N'parameter', N'@EmployeeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_EmployeeField') DROP PROCEDURE dbo.proc_Update_EmployeeField GO CREATE PROCEDURE dbo.proc_Update_EmployeeField ( @EmployeeId Int, @FieldValue NVARCHAR(1500) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='update dbo.Employee set '+@FieldValue+' WHERE EmployeeId ='+ CAST(@EmployeeId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表修改某一列數據的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_EmployeeField', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表修改欄位名及其值如:[Remark]=A', N'user', N'dbo', N'procedure', N'proc_Update_EmployeeField', N'parameter', N'@FieldValue' GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵', N'user', N'dbo', N'procedure', N'proc_Update_EmployeeField', N'parameter', N'@EmployeeId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_Employee') DROP PROCEDURE dbo.proc_Delete_Employee GO CREATE PROCEDURE dbo.proc_Delete_Employee ( @EmployeeId Int ) as DELETE dbo.Employee WHERE EmployeeId = @EmployeeId GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表刪除記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_Employee', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_Employee', N'parameter', N'@EmployeeId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_EmployeeId') DROP PROCEDURE dbo.proc_Delete_EmployeeId GO CREATE PROCEDURE dbo.proc_Delete_EmployeeId ( @EmployeeId varchar(2000) ) as DECLARE @strsql varchar(3000) SET @strsql='DELETE dbo.Employee WHERE EmployeeId in('+@EmployeeId+')' EXEC(@strsql) GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表刪除多條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_EmployeeId', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_EmployeeId', N'parameter', N'@EmployeeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_Employee') DROP PROCEDURE dbo.proc_Select_Employee GO CREATE PROCEDURE dbo.proc_Select_Employee ( @EmployeeId Int ) AS SELECT * FROM dbo.Employee WHERE EmployeeId = @EmployeeId GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_Employee', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_Employee', N'parameter', N'@EmployeeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_EmployeeExists') DROP PROCEDURE dbo.proc_Select_EmployeeExists GO CREATE PROCEDURE dbo.proc_Select_EmployeeExists ( @EmployeeId Int ) AS SELECT count(1) as H FROM dbo.Employee WHERE EmployeeId = @EmployeeId GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表是否存在某記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeExists', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeExists', N'parameter', N'@EmployeeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_EmployeeCount') DROP PROCEDURE dbo.proc_Select_EmployeeCount GO CREATE PROCEDURE dbo.proc_Select_EmployeeCount ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.Employee ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeCount', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeCount', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_EmployeeCountView') DROP PROCEDURE dbo.proc_Select_EmployeeCountView GO CREATE PROCEDURE dbo.proc_Select_EmployeeCountView ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.View_Employee ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表視圖查詢共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeCountView', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeCountView', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_EmployeeTitle') DROP PROCEDURE dbo.proc_Select_EmployeeTitle GO CREATE PROCEDURE dbo.proc_Select_EmployeeTitle ( @FieldName NVARCHAR(100), @EmployeeId Int ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select top 1 '+@FieldName+' from dbo.Employee WHERE EmployeeId ='+ CAST(@EmployeeId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表返回某欄位的標題記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeTitle', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeTitle', N'parameter', N'@FieldName' GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeTitle', N'parameter', N'@EmployeeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_EmployeeFuzzySearch') DROP PROCEDURE dbo.proc_Select_EmployeeFuzzySearch GO CREATE PROCEDURE dbo.proc_Select_EmployeeFuzzySearch ( @FieldList NVARCHAR(1000), @where NVARCHAR(2000) ) AS DECLARE @sql NVARCHAR(4000) IF(@where<>'') SET @where=' WHERE '+@where IF(@FieldList='') SET @FieldList=' * ' SET @sql='select '+@FieldList+' from dbo.Employee '+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表模糊查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_Employee', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_Employee', N'parameter', N'@FieldList' GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_Employee', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_EmployeeAll') DROP PROCEDURE dbo.proc_Select_EmployeeAll GO CREATE PROCEDURE dbo.proc_Select_EmployeeAll AS SELECT * FROM dbo.Employee GO EXECUTE sp_addextendedproperty N'MS_Description', '抽獎員工表查詢所有記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_EmployeeAll', NULL, NULL GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_AwardType') DROP PROCEDURE dbo.proc_Insert_AwardType GO CREATE PROCEDURE dbo.proc_Insert_AwardType ( @AwardProjectId Int, @AwardName NVarChar(200), @AwardPersonNumber Int, @AwardVeryNumber Int, @AwardVeryProduct Int ) AS INSERT INTO dbo.AwardType ( [AwardProjectId] , [AwardName] , [AwardPersonNumber] , [AwardVeryNumber] , [AwardVeryProduct] ) VALUES ( @AwardProjectId , @AwardName , @AwardPersonNumber , @AwardVeryNumber , @AwardVeryProduct ) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 增加記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,項目ID', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardProjectId' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項名稱,如:特等獎,一等獎', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項人數', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardPersonNumber' GO EXECUTE sp_addextendedproperty N'MS_Description', '每次抽的人數', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardVeryNumber' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項每人產品數量', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardVeryProduct' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_AwardTypeOutput') DROP PROCEDURE dbo.proc_Insert_AwardTypeOutput GO CREATE PROCEDURE dbo.proc_Insert_AwardTypeOutput ( @AwardProjectId Int, @AwardName NVarChar(200), @AwardPersonNumber Int, @AwardVeryNumber Int, @AwardVeryProduct Int, @AwardTypeId int output ) AS INSERT INTO dbo.AwardType ( [AwardProjectId] , [AwardName] , [AwardPersonNumber] , [AwardVeryNumber] , [AwardVeryProduct] ) VALUES ( @AwardProjectId , @AwardName , @AwardPersonNumber , @AwardVeryNumber , @AwardVeryProduct ) select @AwardTypeId=@@IDENTITY GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 添加記錄有返回值的存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,項目ID', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardProjectId' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項名稱,如:特等獎,一等獎', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項人數', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardPersonNumber' GO EXECUTE sp_addextendedproperty N'MS_Description', '每次抽的人數', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardVeryNumber' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項每人產品數量', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardVeryProduct' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵輸出', N'user', N'dbo', N'procedure', N'proc_Insert_AwardType', N'parameter', N'@AwardTypeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_AwardType') DROP PROCEDURE dbo.proc_Update_AwardType GO CREATE PROCEDURE dbo.proc_Update_AwardType ( @AwardTypeId Int, @AwardProjectId Int, @AwardName NVarChar(200), @AwardPersonNumber Int, @AwardVeryNumber Int, @AwardVeryProduct Int ) AS UPDATE dbo.AwardType SET [AwardProjectId]=@AwardProjectId , [AwardName]=@AwardName , [AwardPersonNumber]=@AwardPersonNumber , [AwardVeryNumber]=@AwardVeryNumber , [AwardVeryProduct]=@AwardVeryProduct where [AwardTypeId]=@AwardTypeId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 修改記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_AwardType', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,項目ID', N'user', N'dbo', N'procedure', N'proc_Update_AwardType', N'parameter', N'@AwardProjectId' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項名稱,如:特等獎,一等獎', N'user', N'dbo', N'procedure', N'proc_Update_AwardType', N'parameter', N'@AwardName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項人數', N'user', N'dbo', N'procedure', N'proc_Update_AwardType', N'parameter', N'@AwardPersonNumber' GO EXECUTE sp_addextendedproperty N'MS_Description', '每次抽的人數', N'user', N'dbo', N'procedure', N'proc_Update_AwardType', N'parameter', N'@AwardVeryNumber' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項每人產品數量', N'user', N'dbo', N'procedure', N'proc_Update_AwardType', N'parameter', N'@AwardVeryProduct' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵', N'user', N'dbo', N'procedure', N'proc_Update_AwardType', N'parameter', N'@AwardTypeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_AwardTypeField') DROP PROCEDURE dbo.proc_Update_AwardTypeField GO CREATE PROCEDURE dbo.proc_Update_AwardTypeField ( @AwardTypeId Int, @FieldValue NVARCHAR(1500) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='update dbo.AwardType set '+@FieldValue+' WHERE AwardTypeId ='+ CAST(@AwardTypeId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 修改某一列數據的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_AwardTypeField', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 修改欄位名及其值如:[Remark]=A', N'user', N'dbo', N'procedure', N'proc_Update_AwardTypeField', N'parameter', N'@FieldValue' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵', N'user', N'dbo', N'procedure', N'proc_Update_AwardTypeField', N'parameter', N'@AwardTypeId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_AwardType') DROP PROCEDURE dbo.proc_Delete_AwardType GO CREATE PROCEDURE dbo.proc_Delete_AwardType ( @AwardTypeId Int ) as DELETE dbo.AwardType WHERE AwardTypeId = @AwardTypeId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 刪除記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_AwardType', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_AwardType', N'parameter', N'@AwardTypeId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_AwardTypeId') DROP PROCEDURE dbo.proc_Delete_AwardTypeId GO CREATE PROCEDURE dbo.proc_Delete_AwardTypeId ( @AwardTypeId varchar(2000) ) as DECLARE @strsql varchar(3000) SET @strsql='DELETE dbo.AwardType WHERE AwardTypeId in('+@AwardTypeId+')' EXEC(@strsql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 刪除多條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_AwardTypeId', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_AwardTypeId', N'parameter', N'@AwardTypeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardType') DROP PROCEDURE dbo.proc_Select_AwardType GO CREATE PROCEDURE dbo.proc_Select_AwardType ( @AwardTypeId Int ) AS SELECT * FROM dbo.AwardType WHERE AwardTypeId = @AwardTypeId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardType', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardType', N'parameter', N'@AwardTypeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardTypeExists') DROP PROCEDURE dbo.proc_Select_AwardTypeExists GO CREATE PROCEDURE dbo.proc_Select_AwardTypeExists ( @AwardTypeId Int ) AS SELECT count(1) as H FROM dbo.AwardType WHERE AwardTypeId = @AwardTypeId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 是否存在某記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeExists', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeExists', N'parameter', N'@AwardTypeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardTypeCount') DROP PROCEDURE dbo.proc_Select_AwardTypeCount GO CREATE PROCEDURE dbo.proc_Select_AwardTypeCount ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.AwardType ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeCount', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeCount', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardTypeCountView') DROP PROCEDURE dbo.proc_Select_AwardTypeCountView GO CREATE PROCEDURE dbo.proc_Select_AwardTypeCountView ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.View_AwardType ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 視圖查詢共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeCountView', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeCountView', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardTypeTitle') DROP PROCEDURE dbo.proc_Select_AwardTypeTitle GO CREATE PROCEDURE dbo.proc_Select_AwardTypeTitle ( @FieldName NVARCHAR(100), @AwardTypeId Int ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select top 1 '+@FieldName+' from dbo.AwardType WHERE AwardTypeId ='+ CAST(@AwardTypeId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 返回某欄位的標題記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeTitle', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeTitle', N'parameter', N'@FieldName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeTitle', N'parameter', N'@AwardTypeId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardTypeFuzzySearch') DROP PROCEDURE dbo.proc_Select_AwardTypeFuzzySearch GO CREATE PROCEDURE dbo.proc_Select_AwardTypeFuzzySearch ( @FieldList NVARCHAR(1000), @where NVARCHAR(2000) ) AS DECLARE @sql NVARCHAR(4000) IF(@where<>'') SET @where=' WHERE '+@where IF(@FieldList='') SET @FieldList=' * ' SET @sql='select '+@FieldList+' from dbo.AwardType '+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 模糊查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardType', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_AwardType', N'parameter', N'@FieldList' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardType', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardTypeAll') DROP PROCEDURE dbo.proc_Select_AwardTypeAll GO CREATE PROCEDURE dbo.proc_Select_AwardTypeAll AS SELECT * FROM dbo.AwardType GO EXECUTE sp_addextendedproperty N'MS_Description', '獎項表 查詢所有記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardTypeAll', NULL, NULL GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_AwardProduct') DROP PROCEDURE dbo.proc_Insert_AwardProduct GO CREATE PROCEDURE dbo.proc_Insert_AwardProduct ( @ProductAwardTypeId Int, @ProductName NVarChar(400), @ProductNo VarChar(50), @ProductTotal Int ) AS INSERT INTO dbo.AwardProduct ( [ProductAwardTypeId] , [ProductName] , [ProductNo] , [ProductTotal] ) VALUES ( @ProductAwardTypeId , @ProductName , @ProductNo , @ProductTotal ) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表增加記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,獎項類型ID', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductAwardTypeId' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品名稱', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品編號', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductNo' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品數量', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductTotal' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_AwardProductOutput') DROP PROCEDURE dbo.proc_Insert_AwardProductOutput GO CREATE PROCEDURE dbo.proc_Insert_AwardProductOutput ( @ProductAwardTypeId Int, @ProductName NVarChar(400), @ProductNo VarChar(50), @ProductTotal Int, @ProductId int output ) AS INSERT INTO dbo.AwardProduct ( [ProductAwardTypeId] , [ProductName] , [ProductNo] , [ProductTotal] ) VALUES ( @ProductAwardTypeId , @ProductName , @ProductNo , @ProductTotal ) select @ProductId=@@IDENTITY GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表添加記錄有返回值的存儲過程', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,獎項類型ID', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductAwardTypeId' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品名稱', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品編號', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductNo' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品數量', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductTotal' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵輸出', N'user', N'dbo', N'procedure', N'proc_Insert_AwardProduct', N'parameter', N'@ProductId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_AwardProduct') DROP PROCEDURE dbo.proc_Update_AwardProduct GO CREATE PROCEDURE dbo.proc_Update_AwardProduct ( @ProductId Int, @ProductAwardTypeId Int, @ProductName NVarChar(400), @ProductNo VarChar(50), @ProductTotal Int ) AS UPDATE dbo.AwardProduct SET [ProductAwardTypeId]=@ProductAwardTypeId , [ProductName]=@ProductName , [ProductNo]=@ProductNo , [ProductTotal]=@ProductTotal where [ProductId]=@ProductId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表修改記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_AwardProduct', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '外鍵,獎項類型ID', N'user', N'dbo', N'procedure', N'proc_Update_AwardProduct', N'parameter', N'@ProductAwardTypeId' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品名稱', N'user', N'dbo', N'procedure', N'proc_Update_AwardProduct', N'parameter', N'@ProductName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品編號', N'user', N'dbo', N'procedure', N'proc_Update_AwardProduct', N'parameter', N'@ProductNo' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品數量', N'user', N'dbo', N'procedure', N'proc_Update_AwardProduct', N'parameter', N'@ProductTotal' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵', N'user', N'dbo', N'procedure', N'proc_Update_AwardProduct', N'parameter', N'@ProductId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Update_AwardProductField') DROP PROCEDURE dbo.proc_Update_AwardProductField GO CREATE PROCEDURE dbo.proc_Update_AwardProductField ( @ProductId Int, @FieldValue NVARCHAR(1500) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='update dbo.AwardProduct set '+@FieldValue+' WHERE ProductId ='+ CAST(@ProductId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表修改某一列數據的存儲過程', N'user', N'dbo', N'procedure', N'proc_Update_AwardProductField', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表修改欄位名及其值如:[Remark]=A', N'user', N'dbo', N'procedure', N'proc_Update_AwardProductField', N'parameter', N'@FieldValue' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵', N'user', N'dbo', N'procedure', N'proc_Update_AwardProductField', N'parameter', N'@ProductId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_AwardProduct') DROP PROCEDURE dbo.proc_Delete_AwardProduct GO CREATE PROCEDURE dbo.proc_Delete_AwardProduct ( @ProductId Int ) as DELETE dbo.AwardProduct WHERE ProductId = @ProductId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表刪除記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProduct', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProduct', N'parameter', N'@ProductId' GO IF EXISTS (select * from sysobjects where [name] = 'dbo.proc_Delete_AwardProductId') DROP PROCEDURE dbo.proc_Delete_AwardProductId GO CREATE PROCEDURE dbo.proc_Delete_AwardProductId ( @ProductId varchar(2000) ) as DECLARE @strsql varchar(3000) SET @strsql='DELETE dbo.AwardProduct WHERE ProductId in('+@ProductId+')' EXEC(@strsql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表刪除多條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProductId', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵', N'user', N'dbo', N'procedure', N'proc_Delete_AwardProductId', N'parameter', N'@ProductId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProduct') DROP PROCEDURE dbo.proc_Select_AwardProduct GO CREATE PROCEDURE dbo.proc_Select_AwardProduct ( @ProductId Int ) AS SELECT * FROM dbo.AwardProduct WHERE ProductId = @ProductId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProduct', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardProduct', N'parameter', N'@ProductId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProductExists') DROP PROCEDURE dbo.proc_Select_AwardProductExists GO CREATE PROCEDURE dbo.proc_Select_AwardProductExists ( @ProductId Int ) AS SELECT count(1) as H FROM dbo.AwardProduct WHERE ProductId = @ProductId GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表是否存在某記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductExists', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductExists', N'parameter', N'@ProductId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProductCount') DROP PROCEDURE dbo.proc_Select_AwardProductCount GO CREATE PROCEDURE dbo.proc_Select_AwardProductCount ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.AwardProduct ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductCount', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductCount', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProductCountView') DROP PROCEDURE dbo.proc_Select_AwardProductCountView GO CREATE PROCEDURE dbo.proc_Select_AwardProductCountView ( @where NVARCHAR(1000) ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select count(*) as H from dbo.View_AwardProduct ' IF @where<>'' SET @sql=@sql+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表視圖查詢共有多少條記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductCountView', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductCountView', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProductTitle') DROP PROCEDURE dbo.proc_Select_AwardProductTitle GO CREATE PROCEDURE dbo.proc_Select_AwardProductTitle ( @FieldName NVARCHAR(100), @ProductId Int ) AS DECLARE @sql NVARCHAR(4000) SET @sql='select top 1 '+@FieldName+' from dbo.AwardProduct WHERE ProductId ='+ CAST(@ProductId AS VARCHAR(50)) EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表返回某欄位的標題記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductTitle', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductTitle', N'parameter', N'@FieldName' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表主鍵', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductTitle', N'parameter', N'@ProductId' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProductFuzzySearch') DROP PROCEDURE dbo.proc_Select_AwardProductFuzzySearch GO CREATE PROCEDURE dbo.proc_Select_AwardProductFuzzySearch ( @FieldList NVARCHAR(1000), @where NVARCHAR(2000) ) AS DECLARE @sql NVARCHAR(4000) IF(@where<>'') SET @where=' WHERE '+@where IF(@FieldList='') SET @FieldList=' * ' SET @sql='select '+@FieldList+' from dbo.AwardProduct '+@where EXEC(@sql) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表模糊查詢記錄的存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProduct', NULL, NULL GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表要顯示的欄位名的列表', N'user', N'dbo', N'procedure', N'proc_Select_AwardProduct', N'parameter', N'@FieldList' GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表要模糊查詢的欄位條件', N'user', N'dbo', N'procedure', N'proc_Select_AwardProduct', N'parameter', N'@where' GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Select_AwardProductAll') DROP PROCEDURE dbo.proc_Select_AwardProductAll GO CREATE PROCEDURE dbo.proc_Select_AwardProductAll AS SELECT * FROM dbo.AwardProduct GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品表查詢所有記錄存儲過程', N'user', N'dbo', N'procedure', N'proc_Select_AwardProductAll', NULL, NULL GO IF EXISTS (SELECT * FROM sysobjects WHERE [name] = 'dbo.proc_Insert_AwardProductImage') DROP PROCEDURE dbo.proc_Insert_AwardProductImage GO CREATE PROCEDURE dbo.proc_Insert_AwardProductImage ( @ProductImageProductId Int, @ProductImageByte Image ) AS INSERT INTO dbo.AwardProductImage ( [ProductImageProductId] , [ProductImageByte] ) VALUES ( @ProductImageProductId , @ProductImageByte ) GO EXECUTE sp_addextendedproperty N'MS_Description', '獎品圖片表增加記錄存儲過程', N'user', N'd