-- Greate Stored Procedure repalce prc_select_SPNAAM with your Stored Procudre name
IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'P' AND name = '[YourSpName]')
BEGIN
PRINT 'Dropping Procedure [YourSpName]'
DROP Procedure [YourSpName]
END
GO
CREATE PROCEDURE [YourSpName]
(
@parameter int -- your input parameters
)
AS
-- you select statement
GO
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = '[YourSpName]')
BEGIN
PRINT '[YourSpName] Greated'
GRANT EXECUTE ON [YourSpName] TO PUBLIC
END
ELSE
BEGIN
PRINT 'Stored Procedure [YourSpName] not greated!'
END
GO