//问题:想要选择multplple Id并在表格中插入那些ID。
声明@Id varchar(100),@ Sorder varchar(100),@ Sorder1 varchar(100),@ Sorder2 varchar(100),@ attrId varchar(100)
设置@ Id =(从[BB_INTERFACE]中选择ID。[dbo]。[tbl_task_configuration_desc]其中标题为(' MWI Backhaul WSIPT TrunkGroup',
' MWI Backhaul WSIPT新号码范围',
' MWI Backhaul WSIPT演示编号范围',
' MWI互连路由器配置',
' MWI紧急联系人',
' MWI GVA POP分配',
' MWI GVA POP配置',
' MWI Backhaul WSIPT Trunk',
' MWI Handover Service',
' MWI CPOD VLAN分配',
' MWI CPOD VLAN信息',
' MWI移交服务客户组',
' MWI切换服务EMC Multichannel',
' MWI Avaya GVA信息',
' MWI Backhaul以太网信息',
' MWI切换服务互连路由器',
' MWI移交服务联络中心',
' MWI切换服务WFO通话记录',
' MWI切换服务统一通信',
' MWI移交服务新号码范围',
' MWI CPOD VLAN分配组')
)
设置@ Sorder =(从[BB_INTERFACE]中选择max(ScreenOrder)。[dbo]。[tbl_task_configuration_data]其中taskcodeId in(@Id))
设置@ Sorder1 = @ Sorder + 1
设置@ Sorder2 = @ Sorder1 + 1
- 选择@Id作为Taskid,@ Sorder作为lastScreenorder,@ Sorder1作为NewSorder1,@ Sorder2作为NewSorder2 //只发出一个Id,@ Sorder1,@ Sorder2可以在这里选择
插入[BB_INTERFACE]。[dbo]。[tbl_task_configuration_data] (TaskCodeid,的AttributeName,显示名称,可见性,说明,ScreenOrder,控制ModifyDate,恩波,可编辑,验证,手册,IsHighlighted,ROWNUM,ExtendWidth,ChargeAttribute,EditableInJourney,家长) 值 (@id,' crfReference'' crfReference'' 1'' crfReference',@ Sorder1,' TEXTBOX&#39 ;,GETDATE(),' 0'' 0'' 1'' 0'' 0' ' 1'' 0'' 0'' ALL'' 1&#39), (@id,' productVariant'' productVariant'' 1'' productVariant',@ Sorder2,'下拉&#39 ;,GETDATE(),' 0'' 0'' 1'' 0'' 0' ' 1'' 0'' 0'' ALL'' 1') set @ attrId =(从[BB_INTERFACE]中选择Id。[dbo]。[tbl_task_configuration_data]其中taskcodeId在(@Id)和AttributeName =' productVariant'和control =' DropDown') 插入[BB_INTERFACE]。[dbo]。[tbl_task_configuration_data_dropdown] (TaskCodeId,属性Id,的AttributeValue,[启用],AttributeText) 值(@ id,@ attrId,' ACS Premium',' 1',' ACS Premium'), (@ id,@ attrId,' ACS Select',' 1',' ACS Select'), (@ id,@ attrId,' ACS DI',' 1',' ACS DI')
//要求:如何通过设置ID并使用这些ID获取值并插入到两个表中来使其成为动态...在该问题中提供帮助
答案 0 :(得分:0)
Set @TASKID=( select id from [BB_INTERFACE].[dbo]. //get ids [tbl_task_configuration_desc]
where title in
您的ID可能会返回多个值,而上述代码将失败..
所以我建议把它放到临时表中
create table #temp
(
id int
)
insert into #temp
<<your select query>>
最后使用上面的临时表代替taskid以供以后查询
答案 1 :(得分:0)
您可以遵循以下方法:
IF object_id('#TASKID') is not null
drop table #TASKID
SELECT id INTO #TASKID
FROM [BB_INTERFACE].[dbo].[tbl_task_configuration_desc]
WHERE title IN ('MWI Backhaul WSIPT TrunkGroup',
'MWI Backhaul WSIPT New Number Range',
... long list of string constants .....
'MWI Handover Service New Number Range',
'MWI CPOD VLAN Allocation Group')
AND LOB = 'AVAYA bto L2C'
SELECT *
FROM [BB_INTERFACE].[dbo].[tbl_task_configuration_data]
--where AttributeName like'%Product Variant%'
WHERE taskcodeId IN (select id from #TASKID)
SELECT TOP 10 *
FROM [BB_INTERFACE].[dbo].[tbl_task_configuration_data_dropdown]
WHERE taskcodeId IN (select id from #TASKID)
说明:使用您在此select * into new_table from old_table
后面的选择查询在临时表中插入ID,然后在您的其他查询中使用该临时表,例如WHERE taskcodeId IN (select id from #TASKID)