Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
SQL Server 2016 (major build version 13.00.xxxx). Please also tag sql-server.
57
votes
Accepted
Is it generally faster to select into a temp table than selecting into an actual table?
writing to tempdb is faster than an actual table not in tempdb
It's true. There are two IO enhancements in TempDb.
Writes to a table in a user database must have their log records flushed to …
38
votes
What's a good use case for SELECT * in production code?
What’s a good use of select * in production?
IMO only things like this:
eg
create table #foo(a int, b int, c int, d int)
...
select * from #foo
or
with q as
(
select a, b, c
from ...
) …
29
votes
Accepted
SQL Server - Select most recent record from each group when performance is critical
If you have a small-enough number of (StationID, ParameterID) pairs, then try a query like this:
select StationID, ParameterID, m.DateTime LastDate
from StationParameter sp
cross apply
(
sel …
23
votes
Accepted
Seemingly identical WHERE clauses returning different results
They are different strings.
select cast(N'pskalhaq' as varbinary(200))
union all
select cast(N'pskalhaq' as varbinary(200))
outputs
0x700073006B0061006C00680061007100
0x0F20700073006B0061006C0 …
18
votes
Accepted
Is the NOLOCK hint completely safe to use on a table that's guaranteed not to change?
If I have a table where the data is guaranteed to never change, is it completely safe to add the NOLOCK hint to my SELECT queries against that table?
In practice, yes (although not documented as suc …
14
votes
How to Resolve deadlock on concurrent MERGE on two tables
Concurrent MERGE statements will deadlock or produce PK violations by default, as the "scan" phase of the MERGE is performed without a restrictive lock. You need to add a lock hint for this to work. …
12
votes
Accepted
How can I drop a column from a large (700M rows) hot (multiple transactions per second) tabl...
How will SQL Server queue this request (eg First In First Out)? Can I
be sure the DROP COLUMN will truly only take a few moments?
The way the locking works for ALTER TABLE is that you need a Sc …
12
votes
Is OPTION (RECOMPILE) used in production environments?
Yes. OPTION RECOMPILE is appropriate for high-cost/low-frequency queries where the query cost varies significantly by parameter values. As an alternative consider using the Query Store, where you ca …
10
votes
Accepted
No IMPLICIT_CONVERSION warning in this query plan
Your parameters have a lower Data Type Precedence than the columns they are compared to. In this case the parameter values will be implicitly converted. This is a good thing. Converting the column …
9
votes
SQL estimates are way off on DELETE statement with Triggers on huge tables
A table scan on cascade delete is a common symptom of not having proper indexes on your tables.
Ensure that all of the FK tables have indexes supporting the foreign keys. IE a clustered or non-clust …
9
votes
Accepted
Door Number 1, 2, or 3?...Security change, bug, or failed upgrade with an in-place upgrade f...
Door Number 1, 2, or 3:
2, with a dash of 3.
An ownership chain should prevent permission checks on a scalar UDF referenced from a view, so a user with SELECT permission on the view should not also …
9
votes
Accepted
Measuring plan eviction
There's an XEvent for that:
query_cache_removal_statistics
Occurs when a query plan is removed from the plan cache and the
historical statistics for the object are about to be destroyed
S …
8
votes
Mandatory to use "Three Parts Name" in T-SQL statements of SP
Using three-part names in queries that reference objects in the current database is a terrible practice and you should create a rule against it. The most frequent problem with it is that it prevents …
8
votes
varchar(255) or varchar(256)?
The declared size of the varchar rarely has a performance impact1. The data might be actually stored as a rowstore with page compression or row compression. As a Clustered Columnstore, or as a Memor …
8
votes
Accepted
How to connect to microsoft azure?
what would be my storage account?
MYCOMPANYbackups
How can I have access to the backup files?
http://portal.azure.com
or
AzCopy
or
PowerShell
or
Azure Storage Explorer
Where are these …