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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:39:44+00:00 2026-05-14T18:39:44+00:00

Im trying to get the value from BrandID in one table and add it

  • 0

Im trying to get the value from BrandID in one table and add it to another table. But I can’t get it to work. Anybody know how to do it right?

CREATE PROCEDURE AddBrand
AS

DECLARE 
@BrandName nvarchar(50),
@CategoryID int,
@BrandID int

SELECT @BrandID = BrandID FROM tblBrand 
WHERE BrandName = @BrandName

INSERT INTO tblBrandinCategory (CategoryID, BrandID) 
       VALUES (@CategoryID, @BrandID) 

RETURN
  • 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-14T18:39:44+00:00Added an answer on May 14, 2026 at 6:39 pm

    I can see the following issues with that SP, which may or may not relate to your problem:

    • You have an extraneous ) after @BrandName in your SELECT (at the end)
    • You’re not setting @CategoryID or @BrandName to anything anywhere (they’re local variables, but you don’t assign values to them)

    In a comment you’ve said that after fixing the ) you get the error:

    Procedure AddBrand has no parameters and arguments were supplied.

    That’s telling you that you haven’t declared any parameters for the SP, but you called it with parameters. Based on your reply about @CategoryID, I’m guessing you wanted it to be a parameter rather than a local variable. Try this:

    CREATE PROCEDURE AddBrand
       @BrandName nvarchar(50), -- These are the
       @CategoryID int          -- parameter declarations
    AS
    BEGIN
       DECLARE @BrandID int
    
       SELECT @BrandID = BrandID FROM tblBrand WHERE BrandName = @BrandName
    
       INSERT INTO tblBrandinCategory (CategoryID, BrandID) VALUES (@CategoryID, @BrandID)
    END
    

    You would then call this like this:

    EXEC AddBrand 'Gucci', 23
    

    or this:

    EXEC AddBrand @BrandName = 'Gucci', @CategoryID = 23
    

    …assuming the brand name was ‘Gucci’ and category ID was 23.

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

Sidebar

Related Questions

I'm trying to get a value from one of my database values, which will
How can I get a specific value from an object? I'm trying to get
I'm trying to get a value from a netcat connection started at a php
I'm trying to get a value from an array used in the Joomla Plugin
I'm trying to get a value from a NSTextField (Label) and convert it to
I'm trying to get a value from an object in my mac application.
I am trying to get a cell value from the selected item of a
I'm trying to use the value of an asp:HiddenField control in javascript after postback
I'm playing with Silverlight 3 at the mo. I'm trying to get the current

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.