Powershell Update sql string throws error at certain char -


i update sql table powershell.

the field 'tag' gets tag value '0.5.2' wrong value?!

because error message says: incorrect syntax near '.2'.at

anyone knows whats wrong?

0.5.2  [16:05:30][step 5/5] g6a885b5  [16:05:30][step 5/5] invoke-sqlcmd : incorrect syntax near '.2'.at   [16:05:30][step 5/5] c:\teamcity\buildagent\temp\buildtmp\powershell643608974404729980.ps1:12 char:1  [16:05:30][step 5/5] + invoke-sqlcmd -query "update versionmetadata set tag = ${tag}, commitid =   [16:05:30][step 5/5] ${comm ... 

the tag field on versionmetadata string, sql server attempting type conversion of 0.5.2 decimal number when parses (because data isn't formatted string, when gets sql server). , 0.5.2 isn't decimal number.

wrap tag in single quotes tell sql server it's string.

partial query (since don't have full code of script):

invoke-sqlcmd -query "update versionmetadata set tag = '${tag}' 

it safer not use invoke-sqlcmd , string concatenation in way, leaves open breakage/corruption/attack via sql injection, mean doing heavy rewrite of portion of script. preparedstatement safer alternative.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -