Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8063107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:54:39+00:00 2026-06-05T10:54:39+00:00

I have a stored procedure for creating inventory transactions that requires the assembly of

  • 0

I have a stored procedure for creating inventory transactions that requires the assembly of a description. Since other inventory stored procedures will also need to assemble their descriptions similarly, I am trying to create a helper stored procedure.

This helper will use standard parameters and construct the description. The trouble I am having is returning the string Description back to the inventory transaction.

A Inventory transaction calls the helper this way:

declare @TransDescription nvarchar(256) 
declare @TransDescOut nvarchar(256)

EXEC [dbo].[sp_KF_Helpers_CreateInvTransDescription] 
     @TransactionTypeID, @UserName, @OwnerTypeID, @OwnerID, 
     @TransDesc = @TransDescOut OUTPUT

SET @TransDescription = @TransDescOut

Then I use @TransDescription as a value for inserting into column data.

The helper code is:

    CREATE PROCEDURE [dbo].[sp_KF_Helpers_CreateInvTransDescription]
    (   @TransactionTypeID int,
        @UserName nvarchar(256),
        @OwnerTypeID int,
        @OwnerID int,
        @TransDesc varchar(256) OUTPUT
    )
    AS
    BEGIN
    SET NOCOUNT ON;

declare @rslt int = 0
declare @strTyepID varchar(256) = @TransactionTypeID
declare @strOwnerID varchar(256) = @OwnerID
declare @intOwnerTypeID int = @OwnerTypeID
declare @OwnerStr varchar(256) = 'KF_'
declare @OwnerIDStr varchar(256) = (select Description from KF_OwnerType where ID = @intOwnerTypeID)

select @OwnerStr = @OwnerStr + @OwnerIDStr
declare @sql1 nvarchar(4000)

Select @sql1 = 'Select Top 1 (a.Description + '' - '' + ' + @OwnerStr + '.Name) TransDesc 
from KF_InventoryTransactionType a, KF_OwnerType c, ' + @OwnerStr + ' 
where a.ID = ' + @strTyepID + ' and ' 
+ @OwnerStr + '.ID = ' + @strOwnerID 

exec SP_EXECUTESQL @sql1, N'@TransDesc varchar output ', @TransDesc output
 End

As you can see, I am using dynamic SQL to generate the description. The problem is that the help code generates the correct description, but does not pass it back as output.

Anyone know why or where I am losing scope for returning my output description?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:54:41+00:00Added an answer on June 5, 2026 at 10:54 am

    You forgot to assign the variable. Try:

    select top 1 @TransDesc = a.Description + '' - '' + ' + @OwnerStr + '.Name
    ...
    

    Also, change the part where you are declaring the parameter of the dynamic script (@TransDesc), or you will run into another issue. Currently the parameter is being declared like this:

    @TransDesc varchar output
    

    which is equivalent to

    @TransDesc varchar(1) output
    

    Most likely, it should be

    @TransDesc varchar(256) output
    

    instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sql 2008 database and I am creating a stored procedure that
Okay basically I am creating a stored procedure that will return data for our
I have a stored procedure that has the parameter: @desk VARCHAR(50) I want to
I have this stored procedure that I want to use for my SAP crystal
I have a stored procedure that returns data in the format of: Date |
I have a stored procedure in Oracle that returns result set(s) via OUT parameter(s)
I have a stored procedure that returns multiple resultsets just as below CREATE StoredProcedure
I have a stored procedure for SQL Server 2000 that can only have a
I am creating a stored procedure in SQL Server via SSMS. I have written
I have 7 different stored procedures that take in a number of parameters and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.