Most Popular

1500 questions
22
votes
4 answers

Why does my query search datetime not match?

select * from A where posted_date >= '2015-07-27 00:00:00.000' and posted_date <= '2015-07-27 23:59:59.999' But the result contains a record that has posted_date today: 2015-07-28. My database server is not in my country. What is the problem…
lecuong92
  • 293
  • 1
  • 3
  • 8
22
votes
4 answers

Adding an index very slow...is there a mysql cmd to get an ETA or show progress?

I'm currently running an alter query on my table (20M entries) in order to add an index. it's running for more than 3 days already (stuck on 'copy to tmp table'). is there a way I can see the progress of the query or in other word is there a way I…
Atai Voltaire
  • 321
  • 1
  • 2
  • 3
22
votes
4 answers

Convert date yyyy-mm-dd to integer YYYYMM

How can I convert @dateb: SET @dateb = dateadd(month, datediff(month, 0, getdate()) - 3, 0) that returns 2014-04-04 as date to an integer of 201404 Thanks
22
votes
2 answers

Locking in Postgres for UPDATE / INSERT combination

I have two tables. One is a log table; another contains, essentially, coupon codes that can only be used once. The user needs to be able to redeem a coupon, which will insert a row into the log table and mark the coupon as used (by updating the used…
Rob Miller
  • 323
  • 1
  • 2
  • 6
21
votes
2 answers

Select all records, join with table A if join exists, table B if not

So here's my scenario: I'm working on Localization for a project of mine, and typically I would go about doing this in the C# code, however I want to do this in SQL a bit more since I am trying to buff up my SQL a bit. Environment: SQL Server 2014…
Der Kommissar
  • 1,523
  • 1
  • 16
  • 27
21
votes
1 answer

In a MySQL Master/Slave replication, what would happen if I write to the Slave?

Several Questions Would the Slave entry remain until there is an insert/update/delete to the table on the Master that could affect the Slave? If not, how do I ensure that the Slave is in-sync with the Master going forward (either by deleting the…
kfmfe04
  • 849
  • 2
  • 8
  • 12
21
votes
2 answers

Query to List Encryption Certificate for Databases

What certificate is being used to encrypt each of the databases on the instances. I can get the data using the following but how do I write the queries USE master GO -- this provides the list of certificates SELECT * FROM sys.certificates -- this…
21
votes
2 answers

Difference between GROUP BY B,A and GROUP BY COALESCE(B,A)

I have been getting myself very confused. Could somebody kindly explain under what circumstances I would want to use a GROUP BY COALESCE? My guess is that I would use it if I wanted to conditionally group a set of data by column B (if B was not…
Mark McLaren
  • 323
  • 4
  • 13
21
votes
2 answers

Rebuilding the transaction log

We have a very large database (~6TB), whose transaction log file was deleted (while SQL Server was shut down. We have tried: Detaching and reattaching the database; and Undeleting the transaction log file ...but nothing has worked so far. We are…
21
votes
14 answers

Comfortable sqlplus interface?

I found sqlplus'interface is rather outdated. It's quite nice to have some commands or keywords at disposal, but for example no "arrow-up" key for the previous history entry is available. What is a good replacement / extension for sqlplus? Could be…
Sebastian Roth
  • 1,356
  • 3
  • 15
  • 23
21
votes
3 answers

Clustered columnstore indexes and foreign keys

I am performance tuning a data warehouse using indexes. I am fairly new to SQL Server 2014.Microsoft describes the following: "We view the clustered columnstore index as the standard for storing large data warehousing fact tables, and expect it…
21
votes
1 answer

PostgreSQL Common Table Expressions vs a temporary table?

The PostgreSQL documentation on WITH shows the following example: WITH regional_sales AS ( SELECT region, SUM(amount) AS total_sales FROM orders GROUP BY region ), top_regions AS ( SELECT region FROM…
Nathan Long
  • 1,005
  • 2
  • 12
  • 21
21
votes
2 answers

How to backup large MongoDB database

What is the recommended way to back up large data sets in MongoDB? Let's say we have a data size in the order of 10TB - how would you back that up? We're considering a hidden, possibly delayed, replica set node. The delay would protect us from…
Malakim
  • 313
  • 1
  • 2
  • 6
21
votes
3 answers

PostGIS vs. SQL Server for GIS data

So I'm recently starting at a new company and have a lot of ArcGIS users who seem really keen on going forwards with a PostGIS instance to serve some data to our customers. While I don't have an issue with this, we are a 95% SQL Server and 5% Oracle…
LowlyDBA - John M
  • 11,059
  • 11
  • 45
  • 63
21
votes
1 answer

"Limit 1000,25" vs "limit 25 Offset 1000"

Recently I've found out that MySQL has a offset feature. I've been trying to find documentation about the results of offset, or the difference in between offset and the limit variant, but I can't seem to find what I'm looking for. Lets say I have…
Martijn
  • 313
  • 1
  • 2
  • 8