Search code examples
sql-serverinsertselect-insert

Sql insert command ambiguity


I'm trying to use a sql command like this but it's not working for some obvious reasons.Can you tell me what's the way out for this type of commands ?

   INSERT INTO ContentToGroup(ContentId,ClassSectionId)  
   VALUES (16, Select ClassSectionId from ClassSectionMaster where ClassId=1)

Solution

  • INSERT INTO ContentToGroup (ContentId,ClassSectionId)
    Select 16, ClassSectionId
    from ClassSectionMaster
    where classid = 1