例如:有现成表 A ,用于保存自建的数据库表字段,结构如下
id tablename fieldname
现在,新建一个表 B,字段如下
id
title
dsc现在的问题是:如何点一个导入按钮,让 B 的结构插入 A 中结果为:
id tablename fieldname
1 B id
2 B title
3 B dsc
id tablename fieldname
现在,新建一个表 B,字段如下
id
title
dsc现在的问题是:如何点一个导入按钮,让 B 的结构插入 A 中结果为:
id tablename fieldname
1 B id
2 B title
3 B dsc
解决方案 »
- 在SQL Server中,怎样使用表变量来参照已有的表建一个结构完全相同的新表?
- 存储过程写法
- 无法在视图 'authors_VIEW' 上创建 索引,因为该视图未绑定到架构。
- 如何调试SQL Server 2005的存储过程
- 怎样根据表的另两列的值给某一列赋值
- 关于从本地数据库插入远程数据库的问题
- 用Select 选择后导入新表之后出现的问题
- 求sql语句,下一行是以上所有行的合
- 我找到一个很不错的sql安全论坛!~~~~~~~~~~~~~~~~~~
- ??????????????安装proxy client后,为什么SQL SERVER 不能连接 ????????
- 存储过程执行传入像这样的参数时{30278028-852D-41D8-98A3-12658F6B3DB3}出错
- 这个条件分组应该怎么写?
select
b.colid,a.name,b.name
from
sysobjects a,syscolumns b
where
a.id=b.id and object_id('B')=a.id
select
b.colid,a.name,b.name
from
sysobjects a,syscolumns b
where
a.id=b.id and object_id('sysobjects')=a.id
order by
b.colid
select id = ordinal_position ,
tablename = 'B' ,
col_name(object_id('B'),ordinal_position)
from information_schema.columns
where table_name = 'B'
create table B(id int , title varchar(10),[dec] varchar(10))
goinsert into a
select id = ordinal_position ,
tablename = 'B' ,
col_name(object_id('B'),ordinal_position)
from information_schema.columns
where table_name = 'B'select * from Adrop table a , b/*
id tablename fieldname
----------- ---------- ----------
1 B id
2 B title
3 B dec(所影响的行数为 3 行)*/
insert into A
select -(b.offset) as id,a.name,b.name
from syscolumns b , sysobjects a
where a.id=b.id and a.name='b' /**
id name name
------ -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
1 b id
2 b title
3 b dsc(所影响的行数为 3 行)
**/
select id = ordinal_position ,
tablename = 'B' ,
col_name(object_id('B'),ordinal_position)
from information_schema.columns
where table_name = 'B'