Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Posts
    2

    Unanswered: Not able to do insert and select clause with aggregate function

    Hi,

    Could some one help me how to do

    insert into test2(id,name) values ((select max(id) from test1),'user1')
    in MS SQL Server

    its throwing "Subqueries are not allowed in this context. Only sc
    alar expressions are allowed" Exception. Help is appreciated.

    Thanks,
    Murali

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    insert into test2(id,name) select max(id),'user1' from test1
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2006
    Posts
    2
    Thanks for the quick reply. i misinterpreted the query syntax earlier. it worked. Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •