Avatar of Stacey Fontenot
Stacey Fontenot

asked on 

issuse obtaining output with sp_executesql

I am building a stored procedure calls a scalar-valued function that I created.  Example
dbo.retun_alpha( column name, parameter) ,  I have got to the point where I am trying to insert a value in the parameter section based on a table  but am having issue get the value 01  into the function)
I am trying to use SP_ECECUTESQL   below is the code

DECLARE @SQLString nvarchar(max);  
DECLARE @Parm nvarchar(max);
DECLARE @Parm1 nvarchar(max);
declare @args varchar(max);
set @Parm =  'P'+ cast( @I4 as varchar(10))+' from FROM M_TABLE_VALIDATION_RULES WHERE TABLE_VALIDATION_RULES_ID = ' + cast( @TABLE_VALIDATION_RULES_ID  as varchar(max)) + ')';                                                      
set @Parm1 = N'@Value nvarchar(max) OUTPUT'
set @SQLString =  '(SELECT @Value = ' + @Parm
EXEC sp_executesql @SQLString, @Parm1, @Value OUTPUT
set @args = @Value

I am getting

Msg 137, Level 15, State 2, Procedure DATA_CLEANSE, Line 110 [Batch Start Line 7]
Must declare the scalar variable "@Value".
Microsoft SQL Server

Avatar of undefined
Last Comment
Stacey Fontenot
ASKER CERTIFIED SOLUTION
Avatar of Stacey Fontenot
Stacey Fontenot

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Stacey Fontenot
Stacey Fontenot

ASKER

figured it out
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo