如何从其他table得到的资料,填写回去现在的table?
程序代码:
CREATE TABLE #TempFruits ( [Guid] [uniqueidentifier] NULL, [ID] [varchar](512) NULL, [Desc] [varchar](512) NULL ) INSERT INTO #TempFruits([Guid], [ID], [Desc]) VALUES('d001368b-46af-475a-83c3-c8ef40a7de2b', 'USAA', 'UsApple'); INSERT INTO #TempFruits([Guid], [ID], [Desc]) VALUES('35d16568-7ece-4855-a720-19cc96778dc3', 'AFCO', 'AfricaOrange'); INSERT INTO #TempFruits([Guid], [ID], [Desc]) VALUES('0107732a-7438-4f55-a76c-7cadccb47f59', 'THAP', 'ThaiPapaya'); SELECT * FROM #TempFruits DROP TABLE #TempFruits --------------------------------------------------------------------------------------------------- CREATE TABLE #TempCountry ( [Country] [varchar](512) NULL, [AppleGuid] [uniqueidentifier] NULL, [OrangeGuid] [uniqueidentifier] NULL, [PapayaGuid] [uniqueidentifier] NULL ) INSERT INTO #TempCountry([Country], [AppleGuid], [OrangeGuid], [PapayaGuid]) VALUES('USA', null, null, null); INSERT INTO #TempCountry([Country], [AppleGuid], [OrangeGuid], [PapayaGuid]) VALUES('AFRICA', null, null, null); INSERT INTO #TempCountry([Country], [AppleGuid], [OrangeGuid], [PapayaGuid]) VALUES('THAI', null, null,null); SELECT * FROM #TempCountry DROP TABLE #TempCountry --------------------------------------------------------------------------------------------------- CREATE TABLE #TempFromExcel ( [Country] [varchar](512) NULL, [Apple] [varchar](512) NULL, [Orange] [varchar](512) NULL, [Papaya] [varchar](512) NULL, ) INSERT INTO #TempFromExcel([Country], [Apple], [Orange], [Papaya]) VALUES('USA', 'USAA', null, null); INSERT INTO #TempFromExcel([Country], [Apple], [Orange], [Papaya]) VALUES('AFRICA', null, 'AFCO', null); INSERT INTO #TempFromExcel([Country], [Apple], [Orange], [Papaya]) VALUES('THAI', null, null, 'THAP'); SELECT * FROM #TempFromExcel DROP TABLE #TempFromExcel
#TempFruits 和 #TempCountry
这两个是我现在有的table
#TempFromExcel
是我Import资料,来自EXCEL档案
问题来了,现在我有来自EXCEL档案的资料
我该如何从#TempFromExcel join 去 #TempFruits,找出Guid之后
再Update #TempCountry 这个 table呢?
如果做for loop?
一行接一行update
[[it] 本帖最后由 musxell 于 2008-12-2 15:43 编辑 [/it]]