﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / Better Excel Insert procedure? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 08:52:49 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Better Excel Insert procedure?</title><link>http://www.sqlservercentral.com/Forums/Topic904224-149-1.aspx</link><description>[quote][b]Jayded (4/15/2010)[/b][hr]Thanks Wayne! In this instance when I'm making the lists do I have to have a consistency that SQL column 2 points to Excel column 3 such that if someone were to re-sort the Excel spreadsheet and move that column to column 4 that it would no longer work?Would there be a way to tie the two via the column ID in SQL?Ex. Column sCodeID in SQL is currently in Excel column 2 and row 1 is labled as sCodeID but should someone move that to column 8 it would still be ok as the system realizes that the column headed sCodeID belongs with SQL sCodeID regardless of where it is.[/quote]If you are using a Header row in Excel, that becomes the column name. In this case, it will follow.If you don't have a Header row, the columns get names like F1...F255. In this case, you will need to know what column it has been changed to.</description><pubDate>Thu, 15 Apr 2010 14:42:24 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: Better Excel Insert procedure?</title><link>http://www.sqlservercentral.com/Forums/Topic904224-149-1.aspx</link><description>Thanks Wayne! In this instance when I'm making the lists do I have to have a consistency that SQL column 2 points to Excel column 3 such that if someone were to re-sort the Excel spreadsheet and move that column to column 4 that it would no longer work?Would there be a way to tie the two via the column ID in SQL?Ex. Column sCodeID in SQL is currently in Excel column 2 and row 1 is labled as sCodeID but should someone move that to column 8 it would still be ok as the system realizes that the column headed sCodeID belongs with SQL sCodeID regardless of where it is.</description><pubDate>Thu, 15 Apr 2010 13:25:47 GMT</pubDate><dc:creator>Jayded</dc:creator></item><item><title>RE: Better Excel Insert procedure?</title><link>http://www.sqlservercentral.com/Forums/Topic904224-149-1.aspx</link><description>[quote][b]Jayded (4/15/2010)[/b][hr]INSERT INTO MAPPINGTABLESELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Documents and Settings\user\My Documents\Length Adjustments\Mapping\Mapping Table.xls', 'SELECT * FROM [Sheet1$]') [/quote]Try:[code="sql"]INSERT INTO MAPPINGTABLE [b](Col1, Col2, Col3)[/b]SELECT [b]Col1, Col2, Col3[/b] FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Documents and Settings\user\My Documents\Length Adjustments\Mapping\Mapping Table.xls', 'SELECT * FROM [Sheet1$]')[/code]This way you can grab whatever columns you want from the spreadsheet, and put them into specific column in the table.</description><pubDate>Thu, 15 Apr 2010 10:42:16 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>Better Excel Insert procedure?</title><link>http://www.sqlservercentral.com/Forums/Topic904224-149-1.aspx</link><description>We recently purchased a third party tool to run in side by side with our SQL based product. In strategizing the best way to deliver this product to our existing base, we deemed having templates be provided that map the tables in Excel would be the easier procedure to proceed with.One limitation I'm running into is the Insert statement I typically use with other Excel to SQL imports:INSERT INTO MAPPINGTABLESELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Documents and Settings\user\My Documents\Length Adjustments\Mapping\Mapping Table.xls', 'SELECT * FROM [Sheet1$]') Using this statement requires that I have all of the columns in Excel in the same order as the tables I am inserting into. Is there an easy way to tie the SQL column titles to the column titles I'd use in Excel so that I can move the columns in Excel around to make my Excel workflow easier for data entry versus the way that the programmer has the SQL tables aligned?</description><pubDate>Thu, 15 Apr 2010 10:37:35 GMT</pubDate><dc:creator>Jayded</dc:creator></item></channel></rss>