将count(*)值写入另一个表中的方法
一、写入同一个数据库的另一个表中:
代码如下:
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')
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn