why set sql statement to @parameter values and exec @parameter? code example
Example: set parameter sql server
USE AdventureWorks2012;
GO
EXEC dbo.uspGetWhereUsedProductID 819, '20050225';
GO
DECLARE @ProductID int, @CheckDate datetime;
SET @ProductID = 819;
SET @CheckDate = '20050225';
EXEC dbo.uspGetWhereUsedProductID @ProductID, @CheckDate;
GO
EXEC dbo.uspGetWhereUsedProductID 819, GETDATE();
GO
DECLARE @CheckDate datetime;
SET @CheckDate = GETDATE();
EXEC dbo.uspGetWhereUsedProductID 819, @CheckDate;
GO