I have using Microsoft Query in Excel 2007 for the past few weeks and have had many cases where the query works fine in SQL Server 2005 but gives irrelevant errors in Microsoft Query. For example I have this case Multipart identifier error in Excel 2007 MS Query but not in SQL Server 2008 where when I removed the sub queries in SELECT and joined those tables it worked. It doesn't seem to work in this case too.
Pass parameters to temp variables in MS Query on SQL Server from Excel I guess CTEs don't work in MS Query like CTE in MS Query Excel 2007. It doesn't work in this case too. Alternative to Left Join
Can anyone list all the SQL Limitations in Microsoft Query?
I often found that queries that run on Oracle, AS400 and MS Sql wouldn't run on MS Query, I think the reason is because that MS Query always tries to display the query graphically. If the query is impossible to show graphically MS Query will display a waning message and then display just results (not the table or conditional panes). Simple queries work fine but there is a middle ground between complex and simple that MS Query seems to choke on.
The solution I found was not to simplify my queries, but to actually make them more complex thus forcing MS Query not to attempt a graphical display. I did this by making my queries a sub query and entering into MS Query like so:
SELECT * FROM (
--enter your query here
) a
Related
Is there any functionality which work in SQL Server Query similar to as EXCEL Financial RATE() Funtion.
Please suggest me any approach as how to receive the same result by SQL Server Query.
I am trying to run SQL through excel and I have the following SQL query within the data connection:
WITH TEST_DB as (select * from TEST_ADM.KPI_SAMPLE_TEST)
SELECT DISTINCT
BASE.YEAR_MONTH AS YEAR_MONTH
FROM TEST_DB BASE
If I try running this with SQL Developer, it will run successfully, no problems but when I try to run it in Excel, I get the message:
The query did not run, or the database table could not be opened.
Check the database server or contact your database administrator. Make sure the external database is available and hasn't been moved or reorganised, then try the operation again.
Is there some sort of limitation within Excel that prevents me from using WITH statements?
If I remove the statement and select from the table directly, it works but I need to use the WITH data table 6 times in my code and its rather long.
Oh, the database is an oracle database.
I have had an odd error I cannot explain. Basically, I am running a query to my SQL database using excel and am having non-existent data pop up when it comes to a very particular order in my database.
Here is a simple query surrounding this order:
select * from OR200100 where OR200100.OR20001='0000793605'
Here is the output in EXCEL
And here is the same output in SQL
what is happening here? How could the same query generate 2 different results?
Run SQL Server Profiler against the database if you can, then compare the output to the sql query that you are running in ssms.
OK, so it's SQL Server then, that's important because different SQL products can have very different idiosyncrasies and controls.
The next things to check are these:
Is OR200100 a Table or a View? If it's a view then post it's code.
Are you using the same Login/account from both Excel and SSMS?
Are you sure that you are connecting to the same Server and Database? SSMS tells you what you are connected to, but client apps like Excel do not and it is very common for this type of problem to be caused by the app connecting to a Dev or QA version of the database. See here for some of the different ways that this can happen:
So I had a very similar problem, my query was grouping by week numbers. What I found was that one of the queries had set datefirst 5 set whilst the other didn't. I guess the key thing here is make sure, if you are using any SET operations in your ssms queries, these are identical to those in the Excel query string.
I am very new to Access and need a bit help over here.
I was working on MS Access 2007 (in VB) with SQL 2008 Server as my database.
I wanted to show a SQL table in the frontend of Access but faced the problem while using SQL user defined function with my SQL query in Access 2007. I wrote this function and the query in SQL Query design of Access and tried to Run it.. but its showing error (Userdefined "timepart" function not recognized) !!
CREATE function dbo.timepart (#date as SMALLDATETIME)
RETURNS SMALLDATETIME
AS
BEGIN
RETURN #date - DATEADD(d, DATEDIFF(d,0,#date), 0)
END
SELECT * FROM TABLENAME WHERE dbo.timepart(FIELDNAME) Between '9:30' AND '17:30';
I guess MS Access doesn't allow to write UDF SQL functions! I tried this same query in my local SQL Server 2008 database (SQL management studio) and is working perfectly fine.
You should create a pass-through query. With a pass-through query, the code is run on SQL Server and the results are returned to MS Access. You can therefore use SQL Server T-SQL.
Also access-SQL pass-through query (creating SP) error
Attempting to copy/paste a 159KB TSQL query into Microsoft Access 2010 passthrough query editor (to a Microsoft SQL Server 2008 backend).
This produces pop-up error, "The text is too long to be edited".
What is the maximum length of a query in Microsoft Access 2010?
The help file says that the maximum number of characters in a SQL statement
is approximately 64,000. It doesn't mention any difference between pass
through queries and other queries, so in the absence of any specific
documentation I'm assuming that this also applies to pass through queries.
Looking for this myself and found another limitation that is more likely to be your problem as well as mine:
Maximum number of JOINS in a query: 16
Maximum number of nested queries: 50