Excel TSQL convert string to parameter - error “String Data, Right Truncation”.

VA3GJG

New Member
Joined
Apr 3, 2018
Messages
2
I have a SQL query using an ODBC DN connection that works.
However when I change the statement:
HAVING (InvMaster.StockCode = 'SJ8248009600')
to use a parameter:
HAVING (InvMaster.StockCode = ?)
Excel prompts me to link the parameter which is done successfully.
But upon refresh gives the error:
[Microsoft][ODBC SQL Server Driver]String Data, right truncation"​
The reference cell is formatted as text matching the SQL table field and the length of the cell value is the same as the value in the original SQL statement.
I've used this approach before many times but now this fails.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I can't help on the specifics of why this has worked many times before but now fails. This sort of thing is never much fun.

I don't understand why the HAVING clause is used. What if you use a WHERE clause instead?
 
Upvote 0

Forum statistics

Threads
1,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top