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 5946855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:52:54+00:00 2026-05-22T16:52:54+00:00

What do I do incorrectly with passing parameters in this stored procedure?: ALTER PROCEDURE

  • 0

What do I do incorrectly with passing parameters in this stored procedure?:

ALTER PROCEDURE [dbo].[Unload]
    @branch_id INT,
    @fl_close BIT
AS
BEGIN
    SET NOCOUNT ON;
    IF object_ID('TempDb..##ttable','U') IS NOT NULL
        DROP TABLE ##ttable;

    DECLARE @ExecStr varchar(4000),
            @paramlist varchar(4000);
    SElECT @ExecStr = 'CREATE TABLE #ttables
    (
         numid INT identity(1,1),
         uso_id INT
    )     

    INSERT INTO #ttables (uso_id)
    SELECT u2.uso_id FROM Uso u2 WHERE u2.branch_id = @branch_id;'

    SElECT @ExecStr = @ExecStr + 'SELECT identity(int,1,1) as id, c.client_code,
          a.account_num, u.uso_id
    INTO ##ttable
    FROM accounts a INNER JOIN Clients c ON 
          c.id = a.client_id INNER JOIN Uso u ON c.uso_id = u.uso_id INNER JOIN 
          Magazin m ON a.account_id = m.accoun t_id INNER JOIN #ttables tt 
          ON u.uso_id = tt.uso_id 
    WHERE m.status_id IN (1,5) AND a.fl_close = @fl_close AND 
          u.branch_id = @branch_id';

    SElECT @ExecStr = @ExecStr + ';  
            SELECT  id,
                client_code,
                abs_account_num,
                account_new_num,
                account_new_open_date,
                account_close_date,
                uso_id
            FROM ##ttable;
            DROP TABLE #ttables;
            DROP TABLE ##ttable;'

   SELECT @paramlist = N'@branch_id INT, @fl_close BIT';
   EXEC sp_executesql @ExecStr, @paramlist, @branch_id, @fl_close;
  • 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-05-22T16:52:55+00:00Added an answer on May 22, 2026 at 4:52 pm

    The parameter values do pass fine.

    CREATE PROCEDURE [dbo].[Unload]
        @branch_id INT,
        @fl_close BIT
    AS
    BEGIN
        SET NOCOUNT ON;
    
        DECLARE @ExecStr NVARCHAR(4000),
                @paramlist NVARCHAR(4000);
        SELECT @ExecStr = 'select @branch_id, @fl_close'
    
       SELECT @paramlist = N'@branch_id INT, @fl_close BIT';
    
       EXEC sp_executesql @ExecStr, @paramlist, @branch_id, @fl_close
    
       END
    
      GO
    
      EXEC [dbo].[Unload] 20,1
    

    Returns

    ----------- -----
    20          1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make an ajax call by passing named parameters: $this->Js->link('Save',array( 'controller'
I am passing in Dates into an Oracle stored procedure. I keep managing to
This post is incorrectly tagged 'send' since I cannot create new tags. I have
I have a SQL dump file consisting of incorrectly stored Cyrillic Russian ( WINDOWS-1251
I'm trying to call a parameterized stored procedure from SQL Server 2005 in my
I have inherited a project that uses the following pattern for passing parameters from
I read something online that incorrectly stated that standard int [] , etc arrays
There is a related question to this: What's the best method to pass parameters
Good afternoon everyone, I am having an issue with a stored procedure inserting an
I ve follow procedure im SQL Server: alter procedure sp_selectfFriends_by_cities ( @txt_id_usuarios varchar(300) )

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.