Saturday, February 25, 2012

cmd.ExecuteNonQuery() - max length

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

example:


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.

|||

Thanks!

No comments:

Post a Comment