HI
Try following code
CREATE PROC usp_dynamic_exec @where VARCHAR(Max)
AS
BEGIN
DECLARE @strQ AS NVARCHAR(max)
SET @strQ = 'Select * from yourTableName'
IF ISNULL(@where, '') <> ''
BEGIN
SET @strQ = @strQ + ' Where ' + @where -- where clause
END
EXECUTE sp_executesql @strQ
END
GO
Mark as Answer if you find it useful
Shridhar J Joshi Thanks a lot
No comments:
Post a Comment