Most Popular
1500 questions
20
votes
2 answers
Is there a complete list of Online operations for each SQL Server version?
As we are about to change some of the large tables in our 5TB database I found myself needing a list of the operations that can be performed online and the which require full locks to be held while they run. Ideally, this list would also contain…
Thomas Kejser
- 6,218
- 2
- 24
- 46
20
votes
6 answers
MySQL import csv file ERROR 13 (HY000): Can't get stat of /path/file.csv (Errcode: 2)
I am an absolute beginner to MySQL (5.5.34) / Linux (Ubuntu 12.04 LTS)`
I have created a simple database with one table. When trying to import data into it via a 'data_test.csv file an error message 13 appears.
Exert from Terminal follows:
mysql>…
Guillermo
- 203
- 1
- 2
- 5
20
votes
7 answers
How to drop multiple tables with common prefix in one query?
I'm using Microsoft SQL Server 2008.My question is:How to drop multiple tables with common prefix in one query?
something like that table names:
LG_001_01_STLINE,
LG_001_02_STFICHE
Cell-o
- 1,106
- 8
- 21
- 40
20
votes
6 answers
Cannot drop nonexistent constraint and cannot create it either
While testing some migration scripts with a copy of production data (scripts run fine with development data) I found a curious situation. A CONSTRAINT has changed so I'm issuing DROP + ADD commands:
ALTER TABLE A_DUP_CALLE
DROP CONSTRAINT…
Álvaro González
- 1,089
- 5
- 17
- 32
20
votes
1 answer
How to transfer the ownership of the dbo schema in SQL Server 2012
I've accidentally given a user the ownership of the db_owner schema (using the check box in the UI as below) and now I cannot:
Transfer ownership to another user
Drop the user from DB (though I can delete login in the SQL Server)
I tried The…
Preet Sangha
- 907
- 4
- 11
- 22
20
votes
1 answer
Is using DISTINCT as a hint in subqueries useful?
Does adding DISTINCT in the following example have any impact on the query running time?
Is it wise to use it as a hint sometimes?
SELECT *
FROM A
WHERE A.SomeColumn IN (SELECT DISTINCT B.SomeColumn FROM B)
Yosi Dahari
- 517
- 5
- 15
20
votes
5 answers
How to break SQL script execution
I am working on sql script and I am having a requirement of stop continuing the script if some conditions are not satisfied.
When I Google it, I found the RaisError with 20 severity level will terminate it.
But for some reasons I cannot use that…
New Developer
- 473
- 2
- 5
- 9
20
votes
2 answers
What is the difference between COUNT(*) and COUNT(*) OVER()
Take the following code example:
SELECT MaritalStatus,
COUNT(*) AS CountResult
COUNT(*) OVER() AS CountOverResult
FROM (schema).(table)
GROUP BY Marital Status
COUNT(*) Returns all rows ignoring nulls right?
What does…
David Folksman
- 769
- 3
- 8
- 13
20
votes
2 answers
The value could not be converted because of a potential loss of data
Let me start out by clarifying that this is not a duplicate question, nor a potential duplicate for that matter. I have tried implementing every answer to every single variant that already exists of this problem on StackOverflow and DBA Stack…
Mathias Lykkegaard Lorenzen
- 579
- 2
- 5
- 13
20
votes
1 answer
SQL Server nvarchar(max) vs nvarchar(n) affects performance
This is SQL Server 2008 R2 SP2. I have 2 tables. Both are identical (data and indexing), except the first table has a VALUE column as nvarchar(max) and the second has the same column as nvarchar(800). This column is included in a non-clustered…
Brian Bohl
- 303
- 1
- 2
- 6
20
votes
4 answers
Execution plan vs STATISTICS IO order
SQL Server graphical execution plans read right to left and top to bottom. Is there a meaningful order to the output generated by SET STATISTICS IO ON?
The following query:
SET STATISTICS IO ON;
SELECT *
FROM Sales.SalesOrderHeader AS soh
…
anon
20
votes
2 answers
PostgreSQL difference between VACUUM FULL and CLUSTER
I have a table with 200 GB of size occupied by data and 180 GB of size by the 6 indexes on it. It is 30% bloated, so I want to reclaim unwanted space occupied by it. It is clustered on job_id_idx index.
So to reclaim the space do I need to use…
Arun P
- 201
- 1
- 2
- 3
20
votes
2 answers
How to do incremental backup every hour in Postgres?
Trying to do an hourly incremental backup of a single Postgres server (Win7 64).
I have the following setup in postgresql.conf:
max_wal_senders = 2
wal_level = archive
archive_mode = on
archive_command = 'copy "%p"…
Neil McGuigan
- 8,653
- 5
- 42
- 57
20
votes
2 answers
Does MySQL cache queries?
I'm interfacing a MySQL database with PHP Data Objects (PDO) and executing an extensive SQL query. Normally, it takes about 1500 ms; I still need to optimize it. When I run the PHP script twice with a short interval in between, the query only takes…
user24821
20
votes
3 answers
Splitting SQL query with many joins into smaller ones helps?
We need to do some reporting every night on our SQL Server 2008 R2. Calculating the reports takes several hours. In order to shorten the time we precalculate a table. This table is created based on JOINining 12 quite big (tens of milions row)…
Ondrej Peterka
- 463
- 2
- 6
- 10