All pastes #942315 Raw Edit

Someone

public text v1 · immutable
·published 2008-03-14 13:09 UTC
rendered paste body
ALTER PROCEDURE [dbo].[partsUpdateFromCSVFiles] @partFile varchar(MAX), @supplierFile varchar(MAX), @currencyFile varchar(MAX)
AS

-- Bulk insert doesn't like variables ;_;
declare @sql varchar(1000)

begin transaction

exec createTempDBUpdateTables

-- Bulk insert into #temp table
select @sql = 'BULK INSERT #temp_currency FROM ''' +  @currencyFile + ''' WITH ( CODEPAGE = 1252, FIELDTERMINATOR =''|'', ROWTERMINATOR =''\n'' )'
exec (@sql)

-- Bulk insert into #temp table
select @sql = 'BULK INSERT #temp_supplier FROM ''' +  @supplierFile + ''' WITH ( CODEPAGE = 1252, FIELDTERMINATOR =''|'', ROWTERMINATOR =''\n'' )'
exec (@sql)

-- Bulk insert into #temp table
select @sql = 'BULK INSERT #temp_part FROM ''' + @partFile + ''' WITH ( CODEPAGE = 1252, FIELDTERMINATOR =''|'', ROWTERMINATOR =''\n'' )'
exec (@sql) 

-- run updates and inserts.
exec updatePartsSupplierCurrencyFromTempDb

-- Drop #temp tables
drop table #temp_currency
drop table #temp_part
drop table #temp_supplier

commit transaction