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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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