running32
asked on
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
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
How do you do the bulk insert? How do you store the Excel file? What are your seperators?
ASKER
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].tem p2
CREATE TABLE [HealthDistrict].[dbo].[Te mp2] (
[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)
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].tem
CREATE TABLE [HealthDistrict].[dbo].[Te
[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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.Je t.OLEDB.4. 0', TableName='test'].
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.Je