积极答复者
SQLServer2000中如何把指定表中的列数据导出成insert形式的SQL语句?

问题
-
一共有 A B C D 4个表,其中列名ID ,列值为 9002
如何一次性把4个表中ID=9002的一次性导出insert形式的SQL语句?
如果不能一次性导出,也可以分开,导出4个SQL语句文件
- 已编辑 china-dashu 2014年6月14日 17:17
答案
-
Following will give you insert statements for numeric columns:
select 'insert table_n values (' + col1 + ', ' + col2 + ... ')' from table_a where id = 9002
Use following for string columns:
select 'insert table_n values (''' + col1 + ''', ''' + col2 + ... ''')' from table_a where id = 9002
- 已建议为答案 Steven.桦仔 2014年6月16日 1:56
- 已标记为答案 Michelle GeModerator 2014年6月20日 9:37
全部回复
-
Following will give you insert statements for numeric columns:
select 'insert table_n values (' + col1 + ', ' + col2 + ... ')' from table_a where id = 9002
Use following for string columns:
select 'insert table_n values (''' + col1 + ''', ''' + col2 + ... ''')' from table_a where id = 9002
- 已建议为答案 Steven.桦仔 2014年6月16日 1:56
- 已标记为答案 Michelle GeModerator 2014年6月20日 9:37