我正在执行一个 UPDATE .WRITE() 语句,并发现它显然只有在你这样定义时才有效:
string sql = "UPDATE [dbo].[Table] SET [Column].WRITE(@data, @offset, @count) WHERE ...";
...
sqlCommand.ExecuteNonQuery();
但是,如果我使用[dbo].[Table].[Column].WRITE(...)
or [Table].[Column].WRITE(...)
,则会引发异常:
Incorrect syntax near 'WRITE'.
Stack trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
...
这是为什么?它似乎与构建 SQL 语句的通常方式不太一致。这种看似特殊的约定是否有任何意义,显然不允许您明确指定表名和模式?