Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DianGermishuizen/556a0821948b0d92ca4af7a9b515be54 to your computer and use it in GitHub Desktop.
Save DianGermishuizen/556a0821948b0d92ca4af7a9b515be54 to your computer and use it in GitHub Desktop.
/*Variable to hold the value we will filter on at runtime*/
DECLARE @vCustomerID INT;
/*Variable to hold the query string we will alter at runtime then execute*/
DECLARE @vSqlQuery VARCHAR(4000);
/*Define the base version of the query*/
SET @vSqlQuery = '
SELECT *
FROM [dbo].[Customers]
WHERE [Customers].[CustomerID] = ' + @vCustomerID + ''
/*Execute the code*/
EXEC (@vSqlQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment