Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE PROC uspProductSearch @ProductName VARCHAR(32) = NULL AS BEGIN DECLARE @SQL NVARCHAR(MAX) SELECT @SQL = ' SELECT ProductID, ProductName=Name, Color, ListPrice ' + CHAR(10)+ '

CREATE PROC uspProductSearch @ProductName VARCHAR(32) = NULL

AS

BEGIN

DECLARE @SQL NVARCHAR(MAX)

SELECT @SQL = ' SELECT ProductID, ProductName=Name, Color, ListPrice ' + CHAR(10)+

' FROM Production.Product' + CHAR(10)+

' WHERE 1 = 1 ' + CHAR(10)

IF @ProductName IS NOT NULL

SELECT @SQL = @SQL + ' AND Name LIKE @pProductName'

PRINT @SQL

-- parametrized execution

EXEC sp_executesql @SQL, N'@pProductName varchar(32)', @ProductName

END

GO

-- Execute dynamic SQL stored procedure with parameter

EXEC uspProductSearch '%bike%'

  1. What kind of dynamic SQL it is? (such as passing input / output parameters or concatenating the user inputs, etc.)
  2. Explain the problem?
  3. Is this dynamic sql efficient or not? Why?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

3. What are potential solutions?

Answered: 1 week ago