开发者

Check if I can execute some sql-command

I'm using ADO .NET and MS SQL Server 2008.

I have a connection object to a server and a command:

SqlConnection conn = /* my connection*/;
string cmd = "some_sql_command";

I want to check if SQL Server can execute cmd. I don't want to execute cmd, but I want to know If SQL Server can execute it.

cmd can be any single开发者_Python百科 SQL statement, it's not a procedure, transaction or multiple commands etc..


Well, you can always start a transaction, execute the command and then roll back the transaction so that no changes are made to the database.

Another option is to use ServerConnection.ExecuteNonQuery method, which, when passed ParseOnly flag, only parses the command and does not do anything else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜