首先,我在SSIS中从未尝试过类似的东西,而且我对SSIS包的开发还很陌生。
我需要在我的包中构建一个组件,该组件将运行一个数据表(比如80行),并将标题为DisplayOrder的字段设置为自动递增的数字。问题是其中一条记录必须设置为0,然后其余的记录设置为自动递增的数字。
关于代码,我甚至不确定要附加到此问题的代码甚至是什么屏幕截图。
答案 0 :(得分:0)
我终于想通了,不需要循环。
使用的脚本
DELETE FROM [Currency].[ExchangeRates]
使用的脚本
DELETE FROM [Currency].[CurrencyList]
已使用的操作
将值转储到[ExchangeRates]表
使用的脚本
INSERT INTO [Currency].[CurrencyList] (CurrencyCode, CurrencyName, ExchangeRateID, DisplayOrder) SELECT [er].[TargetCurrency] AS [CurrencyCode], [er].[TargetName] AS [CurrencyName], [er].[ID] AS [ExchangeRateID], ROW_NUMBER() OVER (ORDER BY [ER].[TargetName]) AS [DisplayOrder] FROM [Currency].[ExchangeRates] AS [er] ORDER BY [CurrencyName]
使用的脚本
INSERT INTO [Currency].[ExchangeRates] ([Title], [Link], [Description], [PubDate], [BaseCurrency], [TargetCurrency], [TargetName], [ExchangeRate]) VALUES ('1 USD = 1 USD','http://www.floatrates.com/usd/usd/','1 U.S. Dollar = 1 U.S. Dollar',(SELECT TOP 1 [PubDate] FROM [Currency].[ExchangeRates]),'USD','USD','United States Dollar','1')
使用的脚本
INSERT INTO [Currency].[CurrencyList] (CurrencyCode, CurrencyName, ExchangeRateID, DisplayOrder) SELECT [er].[TargetCurrency] AS [CurrencyCode], [er].[TargetName] AS [CurrencyName], [er].[ID] AS [ExchangeRateID], 0 AS [DisplayOrder] FROM [Currency].[ExchangeRates] AS [er] WHERE [er].[TargetCurrency] = 'USD'