页面导航: 首页数据库MsSql → 正文内容 写入另一个表

将count(*)值写入另一个表中的方法

发布:dxy 字体:[增加 减小] 类型:转载
一、写入同一个数据库的另一个表中:  

use db1  
go  
create table t1(  
Item   varchar(100),  
Prov   varchar(100),  
Qty    int);  
insert into t1(item,prov,qty)  
   select '原名','xx省',  
(select count(*)   
from updata where id='A0101'); 

二、写入另一个数据库的表中:  

use db2  
go  
create table t2(  
Item   varchar(100),  
Prov   varchar(100),  
Qty    int);  
INSERT   INTO  t2(item,prov,qty)   
select '原名',  
'xx省',  
(select count(*)  
FROM OPENDATASOURCE('SQLOLEDB',   
'Data Source=YY\IIDC;  
User ID=sa;  
Password=password').  
db1.dbo.updata where  
culindexid='A0101') 
 
浏览次数:载入中... 打印本文关闭本文返回首页

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行