Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Passing Declared and Set parameter to another query in a Stroed Procedure

$
0
0

I Have  th efollowing stored proceedure that is suppose to create a key val:

ALTER

PROCEDURE [dbo].[GenerateNCRId]

@Division

varchar(3),

@DeptCode

varchar(3),

@NCRDetailsID

varchar(50),

@NCRCode

Nvarchar(3)

AS

SET

NOCOUNTON;

BEGIN

Declare

@NCRShortName asNVARCHAR(MAX)

Set

@NCRShortName =N'Select NCRShortName from NCRTypes where NCRTypeID=@NCRCode'

Create

Table #NCRIDs(

NCRID

Varchar(MAX)

)

insert

into #NCRIDs(NCRID)

values(@Division+'-'+@DeptCode+'-'+@NCRShortName+'-'+@NCRDetailsID)

Select

*from #NCRIDs

exec

sp_executeSQL@NCRShortName,N'@NCRCode as Nvarchar (3)', @NCRCode

END

however this is what is returned. i am definitely missing a step.

please help


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>