none
how to use where not condition in insert query?

Answers

  • Hi,

    As INSERT does not have FROM clause, you cannot specify WHERE conditions. If you want to filter the data you'd insert, you may use this kind of query:

    INSERT INTO [yourTable] ([your columns comes here])
    SELECT
    [Columns comes here]
    FROM
    [OtherTable]
    WHERE
    [FilterColumn] NOT IN (val1, val2...);
    

    I hope it help.

    J.


    There are 10 type of people. Those who understand binary and those who do not.
    • Marked as answer by KJian_ Friday, September 09, 2011 2:15 AM
    Friday, September 02, 2011 9:58 AM

All replies

  • Please provide the details what you want and how you were trying to do the same
    Thanks and regards, Rishabh , Microsoft Community Contributor
    Friday, September 02, 2011 9:46 AM
  • Hi,

    As INSERT does not have FROM clause, you cannot specify WHERE conditions. If you want to filter the data you'd insert, you may use this kind of query:

    INSERT INTO [yourTable] ([your columns comes here])
    SELECT
    [Columns comes here]
    FROM
    [OtherTable]
    WHERE
    [FilterColumn] NOT IN (val1, val2...);
    

    I hope it help.

    J.


    There are 10 type of people. Those who understand binary and those who do not.
    • Marked as answer by KJian_ Friday, September 09, 2011 2:15 AM
    Friday, September 02, 2011 9:58 AM
  • Please provide the query details.

    San...
    Friday, September 02, 2011 3:31 PM
  • We cannot use Where clause in Insert....Please specify what you require???
    Saturday, September 03, 2011 6:57 AM