当前位置: 代码迷 >> Sql Server >> SQL插入数据时加下‘’号
  详细解决方案

SQL插入数据时加下‘’号

热度:60   发布时间:2016-04-27 11:21:37.0
求助:SQL插入数据时加上‘’号
现有数据 01 02 03 。。。。
需要插入另一数据库中为 ‘01’,‘02’,'03' .... 需哟如何处理
或是插入后批量能更新也可,谢谢

------解决方案--------------------
SQL code
insert into tb(col) select '''01'''
------解决方案--------------------
SQL code
select '''name1'''--1select ''name1''  --2select 'name1'    --3
------解决方案--------------------
SQL code
-- 更新update tb set col1= ''''+ col1 + '''';
------解决方案--------------------
insert table B(field) select '''' + fieldname + '''' from table A
------解决方案--------------------
4楼的 应该满足你的要求


------解决方案--------------------
仅供参考:
SQL code
CREATE TABLE t1(    id VARCHAR(5))DECLARE @str VARCHAR(2000)='01 02 03'SET @str=REPLACE(@str,' ',''''''' union all select ''''''')SET @str='insert into t1 select [email protected]+''''''''PRINT @strEXEC (@str)SELECT * FROM t1---------------id'01''02''03'
  相关解决方案