locked
cmd.ExecuteNonQuery() - max length RRS feed

  • Question

  • User1130413779 posted

    what the max length that I can run query to sql Server?

    example:


     

    Monday, October 22, 2007 5:19 PM

Answers

  • User-1225738063 posted

    Very large.  I don't believe I've tried over 10 megabytes.  However, I believe that queries up to at least a gigabyte should work.

    You might also think about changing your query so that it follows the syntax:

    INSERT INTO [tblEntentKey] ([acceptID],[enterKey])

    SELECT 1,'12345678-1234-1234-124322432432'

    UNION ALL

    SELECT 1,'...'

    UNION ALL

    ...

     

    I believe you will find it will run much faster than your current query with individual insert statements.  Each insert statement will start and commit a transaction, fire off any triggers, etc.  While the single insert with union all'ed selects will do so under a single transaction/commit/trigger firing.  That is unless of course certain records may fail, and you want the non-failing records to still be inserted.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2007 5:40 PM

All replies

  • User-1225738063 posted

    Very large.  I don't believe I've tried over 10 megabytes.  However, I believe that queries up to at least a gigabyte should work.

    You might also think about changing your query so that it follows the syntax:

    INSERT INTO [tblEntentKey] ([acceptID],[enterKey])

    SELECT 1,'12345678-1234-1234-124322432432'

    UNION ALL

    SELECT 1,'...'

    UNION ALL

    ...

     

    I believe you will find it will run much faster than your current query with individual insert statements.  Each insert statement will start and commit a transaction, fire off any triggers, etc.  While the single insert with union all'ed selects will do so under a single transaction/commit/trigger firing.  That is unless of course certain records may fail, and you want the non-failing records to still be inserted.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 22, 2007 5:40 PM
  • User1130413779 posted

    Thanks! 

    Tuesday, October 23, 2007 3:28 AM