Database Administrators Weekly Newsletter
Database Administrators Weekly Newsletter

Top new questions this week:

Retrieving n rows per group

I often need to select a number of rows from each group in a result set. For example, I might want to list the 'n' highest or lowest recent order values per customer. In more complex cases, the ...

sql-server t-sql greatest-n-per-group  
asked by Paul White 15 votes
answered by Aaron Bertrand 14 votes

In SQL Server, can I guarantee an order without an explicit ORDER BY clause when an index seek is forced on a table with only a clustered index?

Update 2014-12-18 With the overwhelming response to the main question being "No", the more interesting responses have focused on part 2, how to solve the performance puzzle with an explicit ORDER ...

sql-server  
asked by JohnnyM 12 votes
answered by Paul White 13 votes

Excessive sort memory grant

Why is this simple query granted so much memory? -- Demo table CREATE TABLE dbo.Test ( TID integer IDENTITY NOT NULL, FilterMe integer NOT NULL, SortMe integer NOT NULL, Unused ...

sql-server memory execution-plan  
asked by Paul White 12 votes
answered by Paul White 10 votes

Visualizing SQL Server Extended Events data

Lately I've been exploring using Extended Events in SQL Server to help me benchmark and optimize various queries. So far, to view the event data I have been using the "Watch Live Data" feature in ...

sql-server extended-events  
asked by Levi Botelho 8 votes
answered by Shawn Melton 3 votes

Why do we use Group by 1 and Group by 1,2,3 in SQL query?

In SQL queries, we do use Group by clause to apply aggregate functions. But what is the purpose behind using numeric value instead of column name with Group by clause? For example: Group by 1.

mysql plsql group-by syntax  
asked by ursitesion 7 votes
answered by Aaron Bertrand 13 votes

Simple DELETE, but complicated execution plan

When I run this delete: DELETE FROM ETLHeaders WHERE ETLHeaderID < 32465870 ...it deletes 39,157 rows. It should be simple because it is deleting on ETLHeaderID which is the clustered index and ...

sql-server-2008 query-performance execution-plan  
asked by Craig HB 6 votes
answered by Paul White 7 votes

Why doesn't a delete increase unused space in a table?

If I populate the following table: IF OBJECT_ID ('dbo.CleanTableTest', 'U') IS NOT NULL DROP TABLE dbo.CleanTableTest; GO CREATE TABLE dbo.CleanTableTest (FileName nvarchar(4000), ...

sql-server sql delete tablespaces  
asked by itzik Paz 6 votes
answered by Rob Farley 7 votes

Greatest hits from previous weeks:

Connect to sql plus from command line using connection string

Let's say I have a Oracle database. I have a username = x, password = y, database = z. Also I know the port = a, SID = b, Hostname = c. So how do I need to connect correctly? I used many options ...

oracle sqlplus string  
asked by Edvinas 1 vote
answered by eliatou 1 vote

Should developers be able to query production databases?

Should developers be given permission to query (SELECT / read only) production databases? The previous place I worked, the development team had the db_datareader role; where I work now the ...

sql-server best-practices permissions  
asked by Tom Hunter 82 votes
answered by ConcernedOfTunbridgeWells 82 votes

Can you answer these?

Recovery model of current database

I want to know how can I change the recovery model of my current database. I am having sysadm rights.Operating system is windows, Db2 10.5. can some one let me know the command please

db2  
asked by HABBIE 1 vote

How to store a 64-digit key of alpha numerical values into MySQL Database

I am student studying in Database Administration (first year), one of our task requires a to design a login form for corporate and regular users. Below are the requirements for the username and ...

mysql sql database-design regular-expression  
asked by Insidious.C 2 votes

I can't divide 2 count(*) values without returning zero

The statement I'm using is for a KPI in Maximo and I currently have this statement: select (select count(*) from incident where incident.slanum = 'USERADMIN' and incident.actualfinish > ...

sql db2 count cast  
asked by Will 1 vote
Subscribe to more Stack Exchange newsletters


Unsubscribe from this newsletter or change your email preferences by visiting your subscriptions page on stackexchange.com.

Questions? Comments? Let us know on our feedback site. If you no longer want to receive mail from Stack Exchange, unsubscribe from all stackexchange.com emails.

Stack Exchange, Inc. 110 William St, 28th Floor, NY NY 10038 <3