CREATE PROCEDURE [dbo].[GetFruitName]
@quantity int
          SET NOCOUNT ON;

         INSERT INTO Table1(fname,fprice,quantity)
          SELECT f.name,f.price from table2 f,@quantity


but am unable to pass @quantity

closed as unclear what you're asking by HandyD, Mark Sinkinson, Laurenz Albe, Philᵀᴹ, Michael Green Oct 17 at 11:15

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    What is your question? – HandyD Oct 17 at 5:58
  • In addition to asking a question, add the expected results. If the syntax error in the non-working code if corrected, the proc will duplicate all existing rows in the table with the new quantity, It is unclear if that's your intent. – Dan Guzman Oct 17 at 11:00

if @quantity is a "variable" .. I hear "input parameter" to the stored procedure ... then add it to the definition ..


CREATE PROCEDURE [dbo].[GetFruitName] @quantity int

INSERT INTO table1(fname,fprice,quantity)
   SELECT f.name,f.price, @quantity 
      FROM Table2 as f


Not the answer you're looking for? Browse other questions tagged or ask your own question.