Home > OS >  how to pass ' in sql which getting triggered from bask script
how to pass ' in sql which getting triggered from bask script

Time:12-08

we want to run sql insert in BQ but we are using .sh file for this. below is our command and its not working as there is ' in my last insert value("Don't")

bq query --use_legacy_sql=false --label lm:<local_mkt> --label env:<env_var> '
INSERT INTO `<project>.<dataset_source>.reason_table`(cd,cd1,cd2,cd3,desc,dec1) 
VALUES(1,"DCV","AB","AB","SDF","I Don't")'

can anyone help here

CodePudding user response:

Escape character ' with \

bq query --use_legacy_sql=false --label lm:<local_mkt> --label env:<env_var> '
INSERT INTO `<project>.<dataset_source>.reason_table`(cd,cd1,cd2,cd3,desc,dec1) 
VALUES(1,"DCV","AB","AB","SDF","I Don\'t")'

CodePudding user response:

Make double single quotes

select 'I don''t'
  • Related