T-SQL INSERT 子查询例子

1、T-SQL INSERT 子查询例子
INSERT into [dqdata].[dbo].[s_Query_GUI]
	([报表序号]
	)
select
	报表序号
from
	dbo.s_query
2、插入一行
INSERT INTO t_upsNode(
companyId, stateId, upsId, originalUpsName, isActivate, upsManufactId
, upsModelId, upsVersion, agentVersion, ip, PORT, mac, memo, capability
, configOutputPower, configInputVa, configOutputVolt, configInputFreq
, configOutputFreq, createTime, isMonitorService
)
VALUES (
1, 1, "no.01", "测试设备1", TRUE, 1
, (SELECT id upsModelId FROM t_upsModel WHERE CNName = "M9900"),"1.0"
, "1.0", "127.0.0.1", "8080", "123", "备注", 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
, "2018-01-10 10:00:00", TRUE
)

3、插入多行
INSERT INTO t_upsNode (companyId, stateId, upsId, originalUpsName, isActivate, upsManufactId
, upsModelId, upsVersion, agentVersion, ip, PORT, mac, memo, capability
, configOutputPower, configInputVa, configOutputVolt, configInputFreq
, configOutputFreq, createTime, isMonitorService)
VALUES
(1, 1, "no.01", "测试设备1", TRUE, 1
, (SELECT id upsModelId FROM t_upsModel WHERE CNName = "M9900"),"1.0"
, "1.0", "127.0.0.1", "8080", "123", "备注", 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
, "2018-01-10 10:00:00", TRUE),
(1, 1, "no.01", "测试设备1", TRUE, 1
, (SELECT id upsModelId FROM t_upsModel WHERE CNName = "M9900"),"1.0"
, "1.0", "127.0.0.1", "8080", "123", "备注", 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
, "2018-01-10 10:00:00", TRUE )

4、INSERT INTO … SELECT 插入子查询数据
INSERT INTO [dbo].[s_colors]

           (
         
       色组名称, 色号01, 色号02, 色号03, 色号04, 色号05, 色号06, 色号07, 色号08, 色号09, 色号10, 色号11, 色号12, 色号13, 色号14, 色号15, 色号16, 色号17, 色号18, 色号19, 色号20
         
         
           )
   SELECT 
   
 色组名称, 色号01, 色号02, 色号03, 色号04, 色号05, 色号06, 色号07, 色号08, 色号09, 色号10, 色号11, 色号12, 色号13, 色号14, 色号15, 色号16, 色号17, 色号18, 色号19, 色号20
 
 
   
  FROM [dqbak2].[dbo].[s_colors]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值