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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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