i need to develop sql server "dynamic stored procedure " according to passed parameters and bind result into grid view.
below my stored procedure.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
USE DATABASE
GO
CREATE PROCEDURE procedure_name
@LOGIN_ID INT
AS
Declare @SQLQuery AS NVARCHAR(4000)
Declare @ParamDefinition AS NVARCHAR(2000)
Set @SQLQuery = 'SELECT * FROM TABLE WHERE (1=1) '
If @LOGIN_ID = '0'
Set @SQLQuery = @SQLQuery
ELSE
Set @SQLQuery = @SQLQuery + 'AND LOGIN_ID=@LOGIN_ID '
Set @ParamDefinition = '@LOGIN_ID INT'
Execute sp_Executesql @SQLQuery,
@ParamDefinition,@LOGIN_ID
GO
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
please help.
my mail id is :
[email protected]