Writing and Executing Dynamic Query in SQL Server example

3 Comments | 811 Views | Post by: Admin | Tags: Writing and Executing Dynamic Query in SQL Server example


Writing and Executing Dynamic Query in SQL Server example


 Database: I am making use of Microsoft Northwind database,

SQL Snippets:-


CREATE PROCEDURE Customers_GetCustomer
      @CustId CHAR(5)
AS
BEGIN
      DECLARE @SQL NVARCHAR(2000)
      SET @SQL = 'SELECT ContactName FROM Customers WHERE CustomerId = @CustomerId'
      EXEC sp_executesql @SQL, N'@CustomerId CHAR(5)', @CustomerId = @CustId
END

 


Post Comments

if you have some suggestion, question, request on Writing and Executing Dynamic Query in SQL Server example.

Please use the comment box to express your views.

 

Comments:

loading...