views:

27

answers:

0

Here is some sample code:

 DECLARE @sourceFile varchar(255), @testRows int

  SELECT @sourceFile = @xmlInfo.value('(/SelectFile/DataSource)[1]', 'VARCHAR(255)')
  EXEC sp_addlinkedserver 'SomeData', 'Excel', 'Microsoft.Jet.OLEDB.4.0', @sourceFile, '', 'Excel 8.0', ''

   IF @xmlInfo.exist('/ConfigArgs/ParamsXml/ImportDealerData') = 1
   BEGIN
    EXEC(' INSERT INTO TableTest
      SELECT identity_column, col1, col2, Replace(col3, '' '', '''')
      FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',
          ''Excel 8.0;HDR=Yes;Database='+@sourceFile+''', [Sheet1$])')
     SELECT @testRows = @@ROWCOUNT, @totalRows = @totalRows + @@ROWCOUNT
   END

I am also trying to create a format file using the bcp utility, but am not sure how to test it out.

Any help would be greatly appreciated!