Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Help with this Stored proc

Help with this Stored proc

Scheduled Pinned Locked Moved Database
help
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soorma
    wrote on last edited by
    #1

    I am trying to get the questionID from two different Select statements and then insert into a table one by one. DECLARE @NewID INT This one is inserting a new surveyID, Output is SurveyID insert into survey(title,description, surveystatus,CreatedBy,date ) values('New Survey','New Survey',1,'test',Getdate()) SELECT @NewID = SCOPE_IDENTITY() Copying the questions with the new surveyID INSERT SurveyQuestions(surveyid, questions,answertype) SELECT @NewID ,questions,answertype FROM SurveyQuestions WHERE surveyid='81' The problem is below here. I want to get the value of the questionId of the first select statement then the value of the questionID of the second select statement and insert into the table SurveyChoices one by one. Both the select statements can have 1 or 2 or 3 rows or more but the both the select statements will have exact number of rows. select QuestionId from surveyquestions where surveyid=@NewID and answertype <> 'T' select QuestionId from surveyquestions where surveyid='81' and answertype <> 'T' Here i am using the insert statement using the value form First select statement and second select statement INSERT Surveychoices(QuestionId,choice) SELECT questionID,choice((This is the value of the First select statement.) FROM Surveychoices WHERE questionid=questionID(This is the value of the second select statement.)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups