We are into application development and everytime we release the product there are large number of database patches that needs to be run.
Right now these .sql files are being created by the individual developers and the release manager discuss with development team and ordering them and then finally execute them manually.
This is becoming very combursome procedure and trying to automate this process.
Is it possible to write a Stored Procedure that will accept the block of SQL statements as a parameter and then run these block of sql statements?
Generally the .sql statements will have ALTER scripts, INSERT Statements and Update statements etc..
One e.g. is given below
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[RULES]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) begin drop table [dbo].[RULES] IF @@ERROR = 0 print 'Table RULES dropped' ELSE print 'Drop of table RULES failed' END
INSERT INTO [dbo].[MY_CONFIG_WORK] SELECT [CONFIG_SECTION], [CONFIG_KEY],[CONFIG_VALUE_TYPE], [CONFIG_VALUE] FROM [dbo].[MY_CONFIG] GO