SQL with a parameter won't work

zovche

Board Regular
Joined
Mar 21, 2013
Messages
125
Hi all,

I'm creating a SQL statement for ERP Plex database. And I'm struggling with adding parameters with ? in WHERE clause. Parameter is very simple, period in a form YYYYMM, so if I type manually T0.Period=202206 (it works also in text mode '202206') everything is fine, I get hundreds of records. Then I put T0.Period=? and I reference it to the field on another sheet, where in that field I type manually 202206 as a number and as a text, but SQL statement returns zero records, no errors. I tried so many combinations even to convert field like CAST(T0.Period as INT) or CAST(T0.Period as VARCHAR) but just can't get it work with a parameters. I have similar issue with a Date fields, but even stranger is that some SQL's accept date parameter and some don't, but couldn't figure it out what is different, date field formats were exactly the same and parameter field had the same value as well. Any ideas or suggestions?

Appreciate it?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,215,098
Messages
6,123,082
Members
449,094
Latest member
mystic19

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