Mzsmunna
10/15/2019 - 3:18 PM

SP Procedures

Inside Microsoft SQL Server -> dbo -> programmability -> Stored Procedure

------------ CREATE A STORE PROCEDURE WITH / WITHOUT PARAMETERS :

CREATE procedure [dbo].[spTruncateTables]
as
begin
	TRUNCATE Table [HumanaV1].[dbo].Summery

	Select * from [HumanaV1].[dbo].Summery
		
end


CREATE procedure [dbo].[spTruncateTables]
				@type nvarchar(10)
as
begin
	if @type='r'
		begin 
			truncate table MailchimpReport
			select * from MailchimpReport
		End
	else if @type = 's'
		begin
			truncate table Summery
			select * from Summery
		end
		
end

------------- MODIFY A STORE PROCEDURE WITH / WITHOUT PARAMETERS :

ALTER procedure [dbo].[spTruncateTables]
as
begin
	TRUNCATE Table [HumanaV1].[dbo].Summery

	Select * from [HumanaV1].[dbo].Summery
		
end


ALTER procedure [dbo].[spTruncateTables]
				@type nvarchar(10)
as
begin
	if @type='r'
		begin 
			truncate table MailchimpReport
			select * from MailchimpReport
		End
	else if @type = 's'
		begin
			truncate table Summery
			select * from Summery
		end
		
end

--------------- Execute / Run a Store Procedure :

EXEC spTruncateTables;
EXEC spTruncateTables 'r', 's';