USE [DataBase_Name]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE GetData
@MasterType Int
AS
BEGIN
SET NOCOUNT ON;
Select MasterName From TableName Where MasterType=@MasterType
END
GO
If you want to pass more than one parameter u can pass them.. if you want them to be optional parameters u can use like...
Select ColumnNames From TableName Where MasterType=@MasterType and Country=ISNULL(@Country,Country)
If you pass a String like 'Country' or 'State' then you can use
CREATE PROCEDURE GetData
@Input Nvarchar(40)
As
Begin
If @Input ='Country'
Select CountryNames From TableName
Else if @Input='State'
Select StateNames From TableName
Else
Select Columns from Table
End
Check this Link:
http://msdn.microsoft.com/en-us/library/ms187926.aspx[
^]