SimplySql icon indicating copy to clipboard operation
SimplySql copied to clipboard

Invoke-SqlQuery Chinese is not supported

Open Wangwang2021 opened this issue 3 years ago • 2 comments

$data = Invoke-SqlQuery -query "SELECT * FROM someTable WHERE someCol = @var" -Parameters @{var = '你好'}

The above query statement cannot query the data

Wangwang2021 avatar Aug 10 '22 06:08 Wangwang2021

@Wangwang2021 -- the module does not do any manipulation of variables -- it sends them directly to the sql server via parameter bindings. I would suggest querying that column via the module and storing the value in a PS variable and comparing to what you are passing in. Something like this:

$val = Invoke-SqlScalar -query "SELECT someCol FROM someTable WHERE someID = 1"
$testVal = '' # the Chinese characters

# test to see if they are the same
$val -eq $testval

mithrandyr avatar Aug 18 '22 13:08 mithrandyr

@Wangwang2021 -- the module does not do any manipulation of variables -- it sends them directly to the sql server via parameter bindings. I would suggest querying that column via the module and storing the value in a PS variable and comparing to what you are passing in. Something like this:

$val = Invoke-SqlScalar -query "SELECT someCol FROM someTable WHERE someID = 1"
$testVal = '' # the Chinese characters

# test to see if they are the same
$val -eq $testval

thank 。Can you support querying directly based on Chinese parameters in the Sql statement?

Wangwang2021 avatar Sep 02 '22 05:09 Wangwang2021