Note that there are some explanatory texts on larger screens.

plurals
  1. POT-SQL Raiserror Losses Message If Includes Datetime Converted To Char(10)
    text
    copied!<p>Okay, so I am trying to raise an error in T-SQL (SQL-2000). The base Sql code looks like this . . .</p> <pre><code>declare @TmsString char(10), @TmsLast datetime, @UserMsg varchar(500) select @TmsLast = getdate() select @TmsString = ltrim(rtrim(convert(char(10), @TmsLast, 101))) select @UserMsg = '*' + ltrim(rtrim(cast(@TmsString as char))) + '*' raiserror (@UserMsg, 12, 1) return </code></pre> <p>My Managed C++ Code in VS2008 to catch the raiserror looks like this . . .</p> <pre><code>System::Void Sql_ExecuteQuery (SqlCommand ^ sqlCommand, DataSet ^ OutDS, String ^ TableName) { SqlConnection ^ sqlConnect ; SqlDataAdapter ^ sqlDA ; try { sqlDA = gcnew SqlDataAdapter () ; sqlConnect = gcnew SqlConnection (_ConnString) ; sqlConnect-&gt;Open () ; sqlCommand-&gt;Connection = sqlConnect ; sqlDA-&gt;SelectCommand = sqlCommand ; sqlDA-&gt;Fill (OutDS, TableName) ; } catch (Exception ^ excp) { throw gcnew Exception (excp-&gt;Message-&gt;ToString()) ; } finally { sqlConnect-&gt;Close () ; } } </code></pre> <p>Now, I have a breakpoint sest at the catch within the "C++" code. If the raiserror message includes the datetime as a CHAR, the excp->Message is empty. If I remove the datetime as a CHAR and just send a hardcoded raiserror message such as "Error happens here", then the excp->Message is complete and filled in with the raiserror message.</p> <p>Has anybody else seen this type of activity? What can I do on either side of this call . . . i.e., either on the SQL side or the C++ side to get this datetime string included in the raiserror message????</p> <p>Please, help. I am stuck!</p> <p>THANK YOU !</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload