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 |
All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag, like sql-server-2016, since it is often relevant to the question.
5
votes
Table view created with triggers, someone please explain why?
The reason is because the skills for evaluating competence in any discipline are the same skills for competence itself. They thought this design was a good idea because they weren't very skilled in da …
2
votes
How to find out what is causing my Identity column to keep going up
The identity value will be increased if you begin a transaction, insert a row, then rollback the transaction.
I originally thought that Access databases could be a culprit in this, thinking that its …
0
votes
SQL Server: Look for column headers
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%word%'
Join to the TABLES view if you want to exclude views (TABLE_TYPE = 'BASE TABLE').
If you query sysdatabases or sys.databases …
4
votes
2
answers
3k
views
sp_executesql adds statements to executed dynamic script?
The Question:
As far as I can tell, sp_executesql adds statements to the beginning of submitted dynamic SQL script. But, a SQL Profiler trace does not capture the extra statements, and neither does DB …
4
votes
Accepted
Interpreting an execution plan
From your question I gather that your table is relatively small. As you put more rows in the table you'll find that the bookmark lookup stays about the same, and the scan takes longer and longer. Even …
6
votes
Is it a good idea to use Synonyms to avoid creating a duplicate table?
Why do you have 3 databases with the same users?
What happens if one database goes down now?
I'm asking these questions because the Con of the user-source database going down preventing use of the o …
8
votes
Accepted
Is it possible in a view to reference a linked server implicitly rather than explicitly?
CREATE SYNONYM dbo.FooView FOR [LinkedServer].Database.dbo.FooView
Then just use dbo.FooView in your SPs and they can be the same between production and dev.
Note that this is only for SQL 2005 and …
2
votes
Why are queries parsed in such a way that disallows the use of column aliases in most clauses?
In Entity SQL, you CAN use aliases from expressions in other places in the query in some situations:
select k1, count(t.a), sum(t.a)
from T as t
group by t.b + t.c as k1
Note that here you MUST def …
19
votes
Accepted
Why are queries parsed in such a way that disallows the use of column aliases in most clauses?
Summary
There's no logical reason it couldn't be done, but the benefit is small and there are some pitfalls that may not be immediately apparent.
Research Results
I did some research and found some …
2
votes
Accepted
sp_executesql adds statements to executed dynamic script?
I discovered that the server doesn't put the injected script content into the batch, but into the cached execution plan. So, you can only see this happening in profiler if the executed dynamic SQL is …
1
vote
Get start time and end time of a trip in SQL Server
Here's a version that accepts any number of trip/route definitions and pulls all the answers at once. Aside from the join to the routes which should perform well with the right indexes, all the trip s …
8
votes
Does SQL Server read all of a COALESCE function even if the first argument is not NULL?
I just wanted to mention a strategy you may not have considered. It may not be a match here, but it does come in handy sometimes. See if this modification gives you any better performance:
SELECT COA …
3
votes
Why evaluates "IS NULL" in SSMS interactive mode to "TRUE" but the same statement being exec...
Initialize @OUT__USER_ID with NULL, since it is probably being set to a non-null value earlier in your script somewhere.
4
votes
Easily show rows that are different between two tables or queries
Here's a way to show what was asked for:
SELECT
Which = 'TableA',
*
FROM (
SELECT * FROM dbo.TableA
EXCEPT
SELECT * FROM dbo.TableB
) X
UNION ALL
SELECT
'TableB',
*
FROM (
SEL …
2
votes
0
answers
114
views
Syntax for restoring SQL Server backup from non-disk source [duplicate]
I have backed up and restored many a SQL Server database using T-SQL script, but always FROM DISK or TO DISK. I am not a provisioning-concerned database administrator, though, so don't have as much ex …