Everyone. Really need helps to solve my problem.
I've 2 excel file with .xls extension (nota.xls and agt.xls). The first one have 30 columns and the other one only 2 columns. I want to read those from SQL Server with this code:
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\nota.xls;IMEX=1;HDR=YES;','SELECT * FROM [sheet1$]')
But the result from that code is only showing one column. Actually the nota.xls have 2 columns.
The result:
|NoTrans|
Expectation:
|NoTrans|Trans|
It happens too with the agt.xls. Which have 30 columns but only shown 29. I've searching the solution but no ones work. Some site said to change the HDR properties to NO. HDR=NO. But it is not work at all. :(
https://stackoverflow.com/questions/19632567/sql-openrowset-with-excel?rq=1
Try inserting it as .CSV (See Above Answer)
And try to upgrade your architecture as soon as you can i.e. Excel 2007 / SQL Server 2008R2, or higher.
Related
Input Excel/CSV:
SQL Query: -
select 'WWW' as COLUMN_NAME,
(case when to_char (max(WWW)) = to_char(min(WWW)) and to_char(count(WWW)) = count(*) or to_char(max(WWW)) is null then 'same' else 'diff'end)as COMPARISION_VALUE, to_char(max(WWW))as TRANSACTION1, to_char(min(WWW))as TRANSACTION2
from ABC
where Book ='123' and UPDATE_DATE='01-JUN-18';
Note: - I am looking to put this SQL query in loop where first row will pass into the SQL query, then it will check the 2nd row, if the cell is blank it will consider the top most value and COLUMN_NAME will iterate as much we have specified. All the above 4 columns should be parameter.
***Output Console: -***
COLUMN_NAME COMPARISION_VALUE TRANSACTION1 TRANSACTION2
WWW same test test
Expected Output: - I want to save all the transaction in excel/CSV one by one
Please find the attached doc for complete Details
Your question concatenates Excel/CSV as through they're the same thing. They are not. Excel is a very different thing from CSV. Consequently they are two different requirements.
Excel is a binary format which makes it hard to integrate with SQL (although there are third party libraries which can help). CSV is open and text-based, so it's a lot simpler. With an external table you can query a CSV using SQL. Find out more.
As for output, you've tagged your question [plsqldeveloper]. That is the tag for the Allround Automations IDE, which already has excellent capabilities for exporting to Excel or CSV. If you are using that tool you should not reinvent its features. Oracle SQL Developer also already does this (and I suspect TOAD and most of the other IDEs out there do too).
I am try to migrate from access 2003 to 2016 When I am importing my objects everything is fine. Only,on the process of importing 3 tables, I am getting this error.
System resource exceeded
They are big tables too.
There is no hotfix for access 2016, Total table quantity around 100 tables
If you help me I really appreciate
Found solution here:
https://answers.microsoft.com/en-us/msoffice/forum/all/ms-access-2016-system-resource-exceeded/df80f64a-f233-467e-89df-f05a8d58bc77
In short:
task manager/processes tab, find msaccess, right click and select set affinity.... option. I had 6 CPUs ticked (0 to 5). I un-ticked them all and just ticked the 0 CPU.
Since currently there is no hot fix for 2016 version you have to merge either to 2010 or 2013. Then you can try merging to 2016.
Please check this link:
https://social.technet.microsoft.com/Forums/en-US/aedecca8-aa7d-417f-9f03-6e63e36f0c5d/access-2016-system-resources-exceeded?forum=Office2016setupdeploy&prof=required
Not sure if this will help you, but I've managed to resolve this error by wrapping fields referenced in the WHERE clause with Nz e.g.
instead of
WHERE ReportDate = Date
use
WHERE Nz(ReportDate,ReportDate) = Date
It's strange but it seems to work for me, I've found the issue is often related to indexed fields, so I always add it to those fields first
I faced a situation and also searched for it in the internet but could not be able to get any solution.
Problem
My sql server table has 15000 records. It has several columns.
Among all the records, the 'Email ID' column of one record is storing value along with an unidentified character at the beginning. (Please refer to picture attached)
What I want
I want to get rid of that character using sql query. I am using sql server 2012 version.
I tried with 'replace()' and 'patindex()'. I even tried 'stuff' function.
But, its not working. Instead, when I am fetching the data using query, it is showing that typical character.
Please help me with some ideas. If I need to do some settings in database or table, I am ready for that.
Thanks.
Maybe this would be very simple, but I have no idea why this is happening.
To put in simple way, I have inserted a row into a database table which contains a ntext column called content. String value which got in to this column content has a text length of 6889 characters. However when I do a basic select query based on id, it do retrieve the row - but not the complete text from the column Content. All I see in SQL Server Management Studio for this column when I do a select query is the text with characters 43679.
There is no issue with data being inserted and I could see all the text being displayed in front end application. The issue is only when I do a select query, and copy the text to notepad, I do see fewer characters. Anything with respect to SQL Server settings/paging/statistics? Appreciate if anyone could help me out with this.
thanks,
KK
I encountered similar problem, and I found that SSMS is unable to fully retrieve column that is longer than 43680 (in output to Grid mode).
So the work around is output it as XML (unlimited length):
SELECT convert(xml,'<xml><![CDATA[' + cast([your column] as varchar(max)) + ']]></xml>')
Then do a quick search and replace (< to < , > to > ) . You can now copy the result to Notepad++ to view all the content.
SSMS returns a maximum number of characters to the grid or text window of every text based column: SSMS menu: options: Query results node : SQL node : Results to grid / Results to text
I'm sure there is a good reason for this: probably SSMS would fall over even more regularly than it does now.
Hope this helps... no such thing as a silly question
I have some Excel spreadsheets that I cannot change as they are used by another department and they will not change them in future. They are .xlsm with over 500 columns (A:TH). I'm trying to import them into SQL server 2008 on a 64bit machine but I'm having huge problems. All forms of Excel import appear to truncate the columns I select to the first 255.
Ultimately there will 5 separate tables to store this data with 1 common key. I could write a short VBA script to sort the data in Excel into arranged columns of tables at source but I wanted to ask if the following was possible first...
This works fine and selects the columns A:IV
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\NEW.xlsm',
'SELECT * FROM [Details Sheet$A:IV]')
Is there a clever way to do something similar with a non-contiguous range such as
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\NEW.xlsm',
'SELECT * FROM [Details Sheet$C:C,IW:LZ]')
ie. pick up the key in column C and the additional columns IW:LZ? The problem for me is that using the full range C:LZ and SELECT [ID],[THIS],[THAT] FROM etc won't work for fields beyond 255 columns in the range, very annoying!
Have you tried using SSIS to import the Excel files? It can be very picky about data types, but I've never run into a limitation that I couldn't work around with a bit of a Script Component.
It's designed to be a high-performance ETL tool for jobs like what you're trying to accomplish. If you're new to it, check out this article on importing the entirety of Wikipedia as XML into multiple tables.
A quick note is that you may need to install additional Office drivers to read Excel 2007 format, especially on 64-bit machine.