str_lst_to_sql_lst S S 逗号分割的字符串转换为sql里面的字符串 字符串 如: “12,34,56” 结果串 “(’12’,’34’,’56’)” 在当sql里使用拼接字串时,这个转换的结果就不能直接用了,使用拼接情况,需要转换为 ’(’‘12’’,’‘34’’,’‘56’’)‘ 如果能够加上这个支持,会更方便使用。
int main() { string a,sql; a = str_lst_to_sql_lst('cpu_s,cpu_g,XXJ'); sql = 'select * from res where res_id in ' + a; msg(sql); db_run(sql); db_show(); return 1; };
谢谢老师,如果在存储过程里使用的是语句拼接呢,如: declare @s varchar(4000),@list_resid varchar(4000) set @s='select * from res where res_id in ' + @list_resid exec (@s)
登录后方可发贴