PinkeyNBrain
IS-IT--Management
Having trouble with a % symbol in a SQL update statement. The following is largely striped down, but illustrates the issue
Problem is that the actual command I want to send is:
This generates the error, "String or binary data would be truncated". The % symbol is coming from another source and I don't have the option to remove or substitute the symbol. I've tried these:
Working with SQL Server 2005 and MS Excel 2010.
Code:
set rs = New ADODB.Recordset
With rs
.ActiveConnection = con_ref ' assume con_ref set up in preceding code
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
sql_cmd = "UPDATE tblCalc SET buffer_name='CUT ID TOL' WHERE Order = '100254-1-1'"
.Open sql_cmd
End With
Code:
sql_cmd = "UPDATE tblCalc SET buffer_name='CUT % ID TOL' WHERE Order = '100254-1-1'"
Code:
UPDATE tblCalc SET buffer_name='CUT \% ID TOL' WHERE MillOrder = '100254-1-1'
' The above generates the same error message
UPDATE tblCalc SET buffer_name='CUT ~% ID TOL' WHERE MillOrder = '100254-1-1' ESCAPE '~'
' This one generates a syntax error near ESCAPE
UPDATE tblCalc SET buffer_name='CUT ~% ID TOL' WHERE MillOrder LIKE '100254-1-1' ESCAPE '~'
' This goes back to generating the original error message