Import excel file into sql URGENT!!!!!!!!!

I have multiple excel file that I need to get into sql.   I need the file name to be a variable passed by a stored procedure.  I part I am having a problem with is how to I get it into a sql table.  I know I need to create the temp table, but when I try a bulk insert the line all runs together into one column.  I also need to parse out the lastname and first name when uploading.  I'm really desperate to get this working today.  Any help would be greatly appreicated.

The rows in my file are set up as

Name               DOB      Age      Chart#      VisitDt      Provider      Office      Diag1      CPT      SSAN          Sex      Address             City           State      Zip      Rating
Test,Justine      13-May-61      44      s1234      10-Jan-06      d59      mfc      296.7      99211      512-41-4444  m      123 Test Street Test City  CO      12457      z
running32Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SjoerdVerweijCommented:
How do you do the bulk insert? How do you store the Excel file? What are your seperators?
running32Author Commented:
I am storing the excel file on the sql server.

The csv is comma delimited.

I thought I could do the bulk insert as  but it all runs into one column.


drop table [HealthDistrict].[dbo].temp2

CREATE TABLE [HealthDistrict].[dbo].[Temp2] (
[strName] nvarchar (255) NULL,
[dtmdob] smalldatetime NULL,
[lngage] float NULL,
[strchart] nvarchar (255) NULL,
[dtmvisit] smalldatetime NULL,
[strprovider] nvarchar (255) NULL,
[stroffice] nvarchar (255) NULL,
[strDiag] nvarchar (255) NULL,
[strcpt] nvarchar (255) NULL,
[strssnum] nvarchar (255) NULL,
[strsex] nvarchar (255) NULL,
[straddress] nvarchar (255) NULL,
[strcity] nvarchar (255) NULL,
[strState] nvarchar (255) NULL,
[strzip] nvarchar (255) NULL,
[strrating] nvarchar (255) NULL
)
ON [PRIMARY]
GO
BULK INSERT temp FROM 'd:\download\2006.csv' WITH (FIELDTERMINATOR = ',', FIRSTROW=2)
Ved Prakash AgrawalDatabase Consultant/Performance ArchitectCommented:
HI I think you can Use OpendataSource function to Achive this Export thing..

INSERT INTO TABLENAME
(Columnnames)
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 8.0')...xactions

Here you can change file name dynamically

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SjoerdVerweijCommented:
Don't use comma's as separators, not unless you also quote your values. The example record you give would break your structure because Test, Justine would be viewed as 2 fields.
running32Author Commented:
Thisis the error I get when I use the insert.  Thanks

Server: Msg 7314, Level 16, State 1, Line 4
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' does not contain table 'test'.  The table either does not exist or the current user does not have permissions on that table.
OLE DB error trace [Non-interface error:  OLE DB provider does not contain the table: ProviderName='Microsoft.Jet.OLEDB.4.0', TableName='test'].
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.