When I execute this query in apache-zeppelin I get only 100 results with 'Results are limited by 100.' message.
%sql
SELECT ip
FROM log
So I appended 'Limit 10000' in SQL query, but it returns only 100 results again.
%sql
SELECT ip
FROM log
LIMIT 10000
So, How can I get sql results over 100 in zeppelin?
I solved it by myself.
Go Interpreter tab in Zeppelin Home.
Adujust zeppelin.spark.maxResult option in spark Interpreter.
Related
I found the following queries on the internet. The first query is for receiving 100 queries executed on the server,
SELECT TOP 100
deqs.last_execution_time AS [Time],
dest.text AS [Query] , *
FROM
sys.dm_exec_query_stats AS deqs
CROSS apply
sys.dm_exec_sql_text(deqs.sql_handle) AS dest
ORDER BY
deqs.last_execution_time DESC
and the second query displays the users registered in SQL Server.
SELECT * FROM sys.sql_logins
My question is how can I connect these two queries in such a way that it shows the users who have run the queries in the list. Thanks ...
As Charlieface says in the comments, you should set up Auditing to track who is executing what query & when. You can find information about SQL Server Auditing, including how to set it up, on Microsoft Docs: https://learn.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-database-engine
Once you have auditing set up as you want it, you can then execute the following to find the details of the most recent 100 queries:
SELECT TOP 100 *
FROM sys.fn_get_audit_file ('\\serverName\foldername\filename.sqlaudit',default,default)
ORDER BY event_time DESC;
Microsoft SQL Server 2008 R2
I am running a large SQL select query that may take hours to complete. So I try to break the query results into smaller sets.
e.g return results 1-10,000 first, then 10,001 - 20000, and so on
I used below code, but it gave me error
SELECT *
FROM PP_ConsolidatedSalesView
WHERE financial_period = '2018-11'
ORDER BY id
OFFSET 10000 ROWS
FETCH NEXT 10000 ROWS ONLY
I use a loop to dynamically change the offset and fetch next values.
The error message is:
Incorrect syntax near 'OFFSET'
Does anyone have an idea why? And is there an alternative solution?
Can you please confirm the database compatibility level. Offset is present in SQL Server 2012. If database is 2008 compatbility mode, then keyword isnt available.
You can check it like below:
USE AdventureWorks2012;
GO
SELECT compatibility_level
FROM sys.databases WHERE name = 'AdventureWorks2012';
GO
More info here: Incorrect syntax near OFFSET command
I have a simple Perl script that connects to a MS SQL Server 10.50 via freetds. It runs a single query, something like SELECT name FROM table. The table has about 15000 records. I do prepare-execute(no binds)-fetch(in a while loop). Prepare, execute passes OK, fetch loops over about 300 records then hangs and eventually comes back with the "Read from the server failed". In details:
DBD::Sybase::st fetchrow_array failed: OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (36)
Server ....., database ...
Message String: Read from the server failed
The freetds.conf has "tds version" set to 4.2. When I try using 7.0, 7.1 or 7.2, the script doesn't even get past "execute" step.
If I change query to limit results like SELECT TOP 200 name FROM table, it finishes just fine.
Has anyone seen anything like it?
I'm a bit puzzled over a performance problem with our SQL server when using remote query's and applying a where clause. When I run the query on the local server a clustered index seek is used, but from remote this is not the case.
So when running this on the local server it will take 2 seconds:
SELECT * FROM uv_order WHERE order_id > '0000200000'
But running this from a remote database takes 2 minutes:
SELECT * FROM RemoteServer.data.dbo.uv_order WHERE order_id > '0000200000'
Here uv_order is a quite complex view but since an index seek is used when executing from the local server I don't see why it can't use it when running a remote query. This only seams to apply to view since doing the same thing on a table will work as expected.
Any ideas why this happens and how to "fix" it?
Well you can fix it like this
select *
from openquery(
RemoteServer,
'select * from data.dbo.uv_order WHERE order_id > '''0000200000''''
)
I have a table called Table with columns:
ID (int, primary key, clustered, unique index)
TEXT (varchar 15)
on a MSSQL linked server called LS. Linked server is on the same server computer. And:
When I call:
SELECT ID, TEXT FROM OPENQUERY(LS, 'SELECT ID, TEXT FROM Table')
It takes 400 ms.
When I call:
SELECT ID, TEXT FROM LS.dbo.Table
It takes 200 ms
And when I call the query directly while being at LS server:
SELECT ID, TEXT FROM dbo.Table
It takes 100 ms.
In many places i've read that OPENQUERY is faster, but in this simple case it does not seem to work. What can I do to make this query faster when I call it from another server, not LS directly?
What about SELECT ID, TEXT FROM OPENQUERY(LS, 'SELECT ID, TEXT FROM dbo.Table') to make the queries equivalent by using the schema?
Anyway, read this article from Linchi Shea about linked servers
Note: a linked server call will always be slower than a direct call. From SQL Server to your SSMS is now going through another SQL Server instance first, so of course it will be slower.