New data table:
CREATE TABLE [dbo].[szsj_message_list]( [ID] [int] IDENTITY(1,1) not NULL, [name] [nvarchar]( +)NULL, [message] [nvarchar]( the) not NULL, [create_by] [nvarchar]( +) not NULL, [create_date] [datetime] not NULL, [update_by] [nvarchar]( +)NULL, [update_date] [datetime] NULL) on [PRIMARY]
Realize:
CREATE PROCEDURE [dbo].[Op_announce_info] @I_flag nvarchar( +), @id nvarchar( +), @title nvarchar( -), @content nvarchar(2048), @files nvarchar( +), @create_by nvarchar( +), @create_date nvarchar( +) as BEGIN if @I_flag = 'Insert' beginINSERT intoSzsj_announce_info (title, content, files, create_by, create_date) VALUES (@title, @content, @files, @create_by, GETDATE()); End if @I_flag = 'Update' begin UpdateSzsj_announce_infoSetTitle= @title, Content= @content, Files= @files, Update_by= @create_by, Update_date= GETDATE() whereId= @id; End if @I_flag = 'Updatetimes' begin UpdateSzsj_announce_infoSetTimes= IsNull(Times,0)+ 1 whereId= @id; End if @I_flag = 'del' begin DeleteSzsj_announce_infowhereId= @id; End if @I_flag = 'Show' begin Select * fromSzsj_announce_infowhereCreate_datebetween GETDATE()- the and GETDATE(); End if @I_flag = 'Select' Declare @sql NVARCHAR(MAX); Set @sql = 'SELECT * from Szsj_announce_info where 1=1' begin if LEN(@id)> 0 begin Set @sql = @sql + 'and id =" " + @id + " '" ; End if LEN(@create_date)> 0 begin Set @sql = @sql + 'and CONVERT (date,create_date,120) = convert (date," " + @create_date + " ", +)' ; End if LEN(@title)> 0 begin Set @sql = @sql + 'and title like"'%' + @title + '%" " ; End EXECsp_executesql@sql; End END
Database stored procedure Implementation and deletion change (SQL SERVER 2008)