Importing Xls/xlsx File Into SQL
Jul 7, 2007
Hi all,
Actually, I am working in a leading advertisement company where we were handling all of our data in Access, but because our database is getting really large, we have to shift to SQL because queries were taking long time to execute. I have no idea what SQL is. However, i have a problem. In access, i had to import an xlsx(excel 2007 file) in my database. In access I used to do this:
Sub SendTableToExcel()
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, "Campaigns", _
"C:frequentstuffsCampaigns.xlsx", True
End Sub
The format(ie the col Names and structure) in table Campaign and Excel File, is same. I just need to copy the data from excel into SQL. How can i do the same thing in SQL? To be very precise, I am novice to SQL so if explained in a novice languauge, i would really appreciate it!!
Vikas B
Vikas Bhandari
Visit My Blog
www.excelnoob.blogspot.com
View 3 Replies
ADVERTISEMENT
Feb 15, 2008
Hello, I am trying to read a file "xlsx" from ASP, the problem is when I try to delete the file, ASP inform not have permits to delete it, it is as if the connection to file not closing properly, the code is:
Code Snippet
if extension = "xlsx" or extension = "xls" then 'si el archivo es excel
sFilePath = server.MapPath("../tmp/importar/"&archivo)
sDataDir = server.MapPath("../tmp/importar")
sSheetName = "Hoja1"
if extension = "xls" then
sFileConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq="&sFilePath&";DefaultDir="&sDataDir&";"
else
sFileConnectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};READONLY=TRUE;DBQ="&sFilePath&";DefaultDir="&sDataDir&";"
end if
sFileSQL = "SELECT * FROM [" & sSheetName & "$]"
set oFileCN = server.createobject("ADODB.Connection") 'creo objeto adodb
oFileCN.Open sFileConnectionString 'abro el exel
set oFileRS = oFileCN.Execute(sFileSQL) 'selecciono los registros
if not oFileRS.EOF then 'si es distinto de EOF obtengo un array con los valores de las columnas
aSourceData = oFileRS.getRows()
end if
oFileRS.Close
set oFileRS = nothing
oFileCN.Close
set oFileCN = nothing
'asigno los mails a la variabls "readDatafile"
readDatafile = aSourceData
and the error
Microsoft VBScript runtime error '800a0046'
Permission denied
/gestion/edit_import_db_mail.asp, line 27
Any ideas?, Greetings and forgiveness for my English
View 9 Replies
View Related
Oct 23, 2007
Hi,
I uploaded an xlsx file to my reporting services. When i click on the xlsx file link in the reporting services frontend, a internet explorer window is opened with the xlsx file information (reporting services) and the xlsx file is opened by the excel application.
Is there any way to prevent the Internet explorer window to be opened?
Regards.
View 4 Replies
View Related
Apr 15, 2014
I have a job on SQL server agent on SSMS that runs daily, however, where the results go as the query wont appear on the screen.I want to have it automatically save the results from the query to a .csv or an. xlsx file in a specified folder.
View 2 Replies
View Related
Mar 7, 2014
I am using VS2012 and creating a package on a 64bit machine to import some data from a .xlsx file. My question is that I am getting an error for the Excel connection manager, do I need to install some kind of excel drive or excel itself on the machine in order to be able to import the data?
View 6 Replies
View Related
Apr 23, 2015
I have a very simply package using an Excel connection to an XLSX file. It's a straight read of the file and import onto a table.Â
The package works fine in Visual Studio 2008 development and also runs fine when executing on the (server I copied it to) under Integration Services. Â Â
However, under a SQL Agent, the package (32-bit is checked) can not acquire the connection to an excel file.  I use UNC pathing to the file. I've read other posts about similar problems and tried various scheduling options (including Owner of job).  Â
I even tried a to trigger it with a command-line which did not work:Â
"C:Program Files (x86)Microsoft SQL Server100DTSBinnDTEXEC.exe" /sq "our packagesMy_XLSX_File_Import" /SERVER myserver /X86Â /CHECKPOINTING OFF /REPORTING E
All errors are:  "DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0209302."Â
View 4 Replies
View Related
Jun 12, 2015
I have a test server (TEST1) running SQL 2012 and Windows 2012R2. One of the developers wants to use OPENROWSET to read in data from an Excel 2010 file (an xlsx file).
I have loaded the Microsoft Drivers in "AccessDatabaseEngine_64.exe" and enabled the Ad Hoc Distributed Queries option in SQL.
This is the sample code we are working with:
SELECT
X.MEMBID
FROM OPENROWSET(
'MSDASQL',
'Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=etworkserverFolder1Folder2MEMBIDs.xlsx',
'SELECT * FROM [Sheet1$]'
) AS X
I can run the sample query from my laptop with SSMS (I have admin rights) and I can also run it as SA from my laptop. So all is good, right?
But if I RDC into TEST1, I cannot run the query. I get this error:
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver] Your network access was interrupted. To continue, close the database, and then open it again.".
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x574 Thread 0xb74 DBC 0x1d07f08 Excel'.".
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x574 Thread 0xb74 DBC 0x1d07f08 Excel'.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".But wait! It gets better.
I can run the query as SA from TEST1.
And of course, the developer can't run it either.
And it works fine in the production server.
I'm thinking the basics are there but something isn't right in some permission somewhere.
View 9 Replies
View Related
Dec 11, 2014
I have been strunggling to find solution to convert XLSX files with multiple sheets to csv file.
Requirements
>>Â Convert XLSX file with multiple sheets to CSV file
>>Â CSV file names : XLSX filename + '_' + sheet name
>>Â scirpt has to be in VB as i am using ssis 2005
>> I started develping scirpt using Micorosoft.office.interop.Excel.dll . this dll is referenced to script task.
>> found web link as useful.. [URL] ....
View 4 Replies
View Related
May 15, 2006
good morning,
I want to load data that i receive everydays from my customers in .xls file format (excel) or cvs file format, to the database that i have created on this purpose. but when trying to do that whith SSIS; i got an error message .... that i can't import redudant data in my database column.
Best regards.
View 1 Replies
View Related
Oct 17, 2007
Hi,
I am using Excel datasource and Excel destination in a simple SSIS package which i created. I have got two queries regarding this
How does excel datasouce/destination accept .xlsx files, since i observed that they accept only .xsl file
Does excel destination ascept .xlsm files, because i have some macros enabled in destination
Thanks in advance for advice
Warm Regards,
gchanduu.
View 3 Replies
View Related
Jun 22, 2007
Hi i'v e installed the file: SQLServer2005_DTS.msiBecause i've heard that i need that to import a csv file into a ms sql database. now i have no idea how to work it, like to even make it open.Where would i open it from? I reckon i'v eread enough literature about using it, to be able to have a bash... thanks in advance...
View 3 Replies
View Related
Oct 5, 1999
Hi, this is my first time and was wondering what's the best way to do the following:
i've sql server 6.5. also have a sql database(.DATfile) in a folder.
i need to import this database to my server. should i just LOAD/import it? or do i need to first create a database device on my server(how much size should i allocate etc) and then load it??
thanks a lot
rohit
View 3 Replies
View Related
Jun 24, 2002
Hi guys,
I have to write a Store procedure which will pickup a txt file from a destination, read it and update some table.
How to pick and read a txt file in a Stored procedure.
Thanks in advance
Vineet
View 1 Replies
View Related
Jun 11, 2007
Hi,
i am having problems while importing a .csv file.
when i import a .csv file in sql server I get the folowing error message.
"Cannot create an OLE DB accessor. Verify that the column metadata is valid".
Any help would be appreciated
View 3 Replies
View Related
Jul 23, 2005
I have a .txt file that I need to add to an existing table, which ismade up of Varchar, Char, numeric and int fields.What is the best way to do it.The first thing I tried was importing the .txt file, and then goinginto the design and changing the field type, but I hit problems on theNumeric fields.Then I tried changing the field types from varchar to different typesat the transfom stage of importing, but that failed too.Regards,Ciarán
View 2 Replies
View Related
Nov 22, 2007
I have a CSV file that i need to import into a SQL table. The problemis the values in the first column are not brackited in "". There areover 700K rows. Is there an easy way to fix the data or have SQLcorrectly import the the data?The data looks like this1, "xxx","zzz"2, "aaa","bbb"an so on...Thanks
View 1 Replies
View Related
Sep 19, 2006
Hi all-
I am in need of some help importing a .CSV file into a SQL Server 2005 Express database. I can't use SSIS because it's SQL Server Express. The operation needs to run as a parameterized Stored Proc which I will call from ASP.NET.
The problem is that I need to get the only 2 columns from the text file, then "tack on" 3 more columns that will have data that changes, which will come in as parameters to the T-SQL stored proc. This prevents me from using a straight BULK INSERT.
The data in each of these columns will be the same for each record in that column - that is, every record in every field in column 3, for example, will be the same.
Some of the files will have 4 million records and up, so speed is of the essence here. I tried using BULK INSERT to dump the data into a #temporary table - which took 38 seconds and was acceptably fast - but then, my next step was to dump the additional data into the other columns using UPDATE... SET. I gave up on this after the query ran for THIRTY MINUTES! My next step was going to be to move the data from the temporary table into the target permanent table somehow, but I never got that far when I saw how long the previous step took...
It's a little odd, because I can do the same thing in MS Access in under 5 minutes by using a SQL statement like this in my ASP.NET code:
"INSERT INTO [Target_Table] (field1, field2, field3, field4)" & _
"SELECT F1, F2, '" & strSource & "', Now() AS DateTimeStamp " & _
"FROM [Text;HDR=NO;DATABASE=" & strPath & ";].[" & strFilename & "]"
strSource is a string that the User enters (properly vetted for security); strPath and strFilename are strings holding the path and filename to the .CSV file. I create a unique filename from the file the user uploads. This works in under 5 minutes for several millions of records in MS Access, as I said above. I've had no luck getting anything similar to work in SQL Server, though.
Anyway, does anyone have any ideas? This is somewhat urgent, as the project was about to go "live" when it was discovered that the actual, live data had grown to the point where Access couldn't hold it, and a move to SQL Server Express was necessary.
Thanks in advance,
-Andrew
View 9 Replies
View Related
Sep 19, 2005
I need to be able to create a DTS package that imports a CSV file which is loated at URL. I.E. HTTP://www.url.com/csv/thefile.xls I tried copying the URL an pasting it in the file location when in SQL wazird but I got an error message.
View 1 Replies
View Related
Jun 4, 2007
I'm a newbie to SSIS, so there is probably an easy solution:
I'm importing from a csv file into a db table, but would like to remove the quotation marks from around the data before inserting into the table.
Are there any suggestions of how to remove the "data" marks? Would a Foreach Loop container work for this?
View 1 Replies
View Related
Jul 31, 2007
How do i import a Excel file into a table i have created in my database in SQL server 2005???
View 10 Replies
View Related
May 1, 2008
Happy Thursday all,
I am importing a text file to sql and most of my fields look like this:
"M","NEW ADDRESS",
and my other field looks like this:
"firstname Lastname"
but I need it like this:
"firstname", "Lastname"
Can anyone help me understand a better way of making this happen?
Thanks in advance
View 2 Replies
View Related
Jul 22, 2004
Can someone please help me.
I need to import a csv fiel to sql server and I know that the column delimiter is
and the newline delimiter is but I don't know what the rowterminator is or the fieldterminator. How can I import the file into an empty table in an existing database.
Any suggestions would be greatly appreciated.
View 1 Replies
View Related
Sep 15, 2004
HI Guys,
I am doing the following to read the data in a text file and inserting it into SQL.
1) Open db connection
2) Open Text File
3) loop through text file all along inserting each row into the db
4) close the text file
5) close the db connection
However, the text file has over 400 rows/lines of data that need to be inserted into the db. Each line in the text file is a row in the db. At anyrate, the above script times out. Is there a better, faster way to do this? I can't use Bulk Insert due to permissions previlages.
Thanks in Advance!
View 2 Replies
View Related
Sep 4, 2001
Hi all,
Please let me know if it is possible to import an Oracle .dmp binary file into SQL using DTS. DTS has ODBC and OLE DB drivers for Oracle but both require specifying the Oracle database name, user name and password. i.e., it looks like the only way to import the .dmp file into SQL would be to first load the .dmp file into Oracle and then tranfer it from Oracle to SQL using DTS. Is there any way to load the .dmp file directly into SQL?
The .dmp file is a binary file that has been generated from Oracle using the 'Export' utility.
Thanks in advance,
-Praveena
View 2 Replies
View Related
Dec 6, 2000
I have large flat files that I need to import using DTS. The record counts are between 500,000 and 3000,000. Or, 16 to 116 MB. When creating the DTS package I need to use to import, the wizard is haulting at the point where I should place the fixed points for the fields. I thinks it is because, the wizard will only recognize excel or text files. I cannot save these files as either txt or xls, because of their size. does anybody have any suggestions?
View 3 Replies
View Related
May 19, 2004
I am building a aspx/c# application with SQL Server 2000 backend. Now i want to have the option for "Importing" the data into one of the tables in my database.
The source file for the import is a text file , CSV format. I want the users to click on the "Import" button placed on my webform and supply the souce file and the data should get imported into the SQL Server 2000 database table.
I want to know the various ways to implement this. Is it possible to invoke the DTS and then DTS will itself guide the users do the import? or if i need to write a SQL query , what would that be like??
View 2 Replies
View Related
Feb 14, 2007
I have an app written in delphi v5 with a MS SQL Database and I'm struggling with an import feature i need
The user needs a function to import Contact data from a txt/csv file into the Contact Table
Details of feature:
the user enters the different parameters into the Delphi app e.g.
File Location
Files Includes Column Headings or not
Whether the file Comma or Tab Seperated
Mapping the fields
Then i need to use those parameters and run some sort of import routine putting the data into the specific table.
The tables consists of 3 fields - First Name, Surname, Mob Number - but these fields can be in any order in the file. for example Col 1 (in file) needs to go into Field 3 in DB. this is sorted in the Mapping Fields above
How do I do this using MS SQL??
I've been looking at using the BULK INSERT command e.g
BULK INSERT Contact
FROM 'C:Import_data.csv'
WITH
{
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
}
but at the minute i just get error -
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation.
Is this the correct command to use??
Do you know any websites that can point me in the right direction??
I have an app written in delphi v5 with a MS SQL Database and I'm struggling with an import feature i need
The user needs a function to import Contact data from a txt/csv file into the Contact Table
Details of feature:
the user enters the different parameters into the Delphi app e.g.
File Location
Files Includes Column Headings or not
Whether the file Comma or Tab Seperated
Mapping the fields
Then i need to use those parameters and run some sort of import routine putting the data into the specific table.
The tables consists of 3 fields - First Name, Surname, Mob Number - but these fields can be in any order in the file. for example Col 1 (in file) needs to go into Field 3 in DB. this is sorted in the Mapping Fields above
How do I do this using MS SQL??
I've been looking at using the BULK INSERT command e.g
BULK INSERT Contact
FROM 'C:Import_data.csv'
WITH
{
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
}
but at the minute i just get error -
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation.
Is this the correct command to use??
Do you know any websites that can point me in the right direction??
Hope all this makes sense
Thanks
View 1 Replies
View Related
Jul 25, 2006
Is there a specific way i shoudl setup the way i export my tables tfom mysql to import them into MSSQL? Im exporting it to .sql and i have tried a bunch of different options but every time i try to import the .sql file to MSSQL i get stuff like this
There was an error importing the database. The status of the import is unknown.
Incorrect syntax near '='.
Incorrect syntax near '`'.
also... how hard would it be to import a .TAB file (which is a csv file but uses tabs instead of commas)?
View 14 Replies
View Related
Feb 14, 2007
I have an app written in delphi v5 with a MS SQL Database and I'm struggling with an import feature i need
The user needs a function to import Contact data from a txt/csv file into the Contact Table
Details of feature:
the user enters the different parameters into the Delphi app e.g.
File Location
Files Includes Column Headings or not
Whether the file Comma or Tab Seperated
Mapping the fields
Then i need to use those parameters and run some sort of import routine putting the data into the specific table.
The tables consists of 3 fields - First Name, Surname, Mob Number - but these fields can be in any order in the file. for example Col 1 (in file) needs to go into Field 3 in DB. this is sorted in the Mapping Fields above
How do I do this using MS SQL??
I've been looking at using the BULK INSERT command e.g
BULK INSERT Contact
FROM 'C:Import_data.csv'
WITH
{
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
}
but at the minute i just get error -
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation.
Is this the correct command to use??
Do you know any websites that can point me in the right direction??
Thanks
View 2 Replies
View Related
Feb 27, 2008
Hello Everybody,
I am importing an csv file into Sql Server straight forward no data cleansing or anything and i noticed everyday it misses the last row in the CSV file.
Has anybody come accross this if so is there anything that i can do to get that row.
ANY HELP ON THIS IS GREATLY APPRECIATED.
Thanks In advance....
View 5 Replies
View Related
Apr 18, 2012
I have a stored procedures that will import 28 CSV files with different columns layout for each one, into their own table in SQL Server 2008 and a master stored procedure which will execute the other 28 store procedures.
All the CSV files are stored on the network drive in one folder.The naming of these files will vary from week to week and I don't want to manually change the names in the stored procedures. Each table name has a unique Identifier F1 to F28 that will be a constant before the rest of the name for example ...
F1_country23
F2_region12
Can I use the unique Identifier to add an wildcard or variable to the stored proc so it will pick any file in the folder for example with "F1" or "F2" meaning format layout 1 or 2 and use the correct stored procedure like below?
WHEN 'F1' THEN 'usp_F1_ImportScript'
WHEN 'F2' THEN 'usp_F2_ImportScript'
Example SQL scripts so far ...
Code:
Create PROC [dbo].[usp_F1_ImportScript]
-- Check if template table already exists and if it does then delete the table
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CSVTest]') AND type in (N'U'))
DROP TABLE dbo.CSVTest
-- Create a new template table
[Code] ....
the SP which will run the 28 SP
Code:
CREATE PROCEDURE [dbo].[usp_FilePicker] (@FileName VARCHAR(255))
AS
--check if @FileName is null
IF @FileName IS NULL
BEGIN
SELECT 'No Files Match' AS ERROR
[Code] .....
I cannot use SSIS because other users from different countries (50+ so far) may need to add/delete columns in the raw text/cvs files (for their own test environment) meaning there may be changes needed to made to the SQL scripts and with documentation any user without experience with MSSQL would be able to make simple changes.
View 1 Replies
View Related
Feb 18, 2004
Hello Guys,
I Hava a Source text connection and I'd like to take just the first row ( the header, of course) of the file to one table. How can I get this??
Tis is quite Urgent.
Thanxs;
View 5 Replies
View Related
May 6, 2004
I am trying to import some data from a csv file on a regular basis. This file, however, is stored on a website. I can't seem to find a way, either using DTS or a stored procedure to make this task simple. If the file is at http://www.mysite.com/import.csv is there anyway I can get DTS to download that file and import it into a new table?
Thanks,
Scott
View 3 Replies
View Related