I am trying to make my integration tests more idempotent. One idea was to roll back after each test, another idea was how programmatic parsing of the text is similar to the green flag in Query Analyzer or SSMS.
How do I get SQL Server to parse my command without using it using ADO.NET?
UPDATE: This is what finally worked as desired:
using (DbCommand executeOnly = Factory.DbCommand()) { executeOnly.Connection = command.Connection; executeOnly.CommandType = CommandType.Text; executeOnly.CommandText = "SET NOEXEC ON;" + sqlCommand; executeOnly.Connection.Open(); executeOnly.ExecuteNonQuery(); }
For inexplicable reasons, " SET PARSEONLY ON " only worked in Query Analyzer. I could not install this on an ADO.NET connection. This is also good, because PARSEONLY seems to catch only syntax errors, which is not a common error. SET NOEXEC ON will cover wider error options, such as a view that refers to a missing table or column, or a missing parameter in a stored procedure.
MatthewMartin Jun 21 '10 at 11:57 on 2010-06-21 11:57
source share