Viewing 15 posts - 19,606 through 19,620 (of 22,219 total)
It's not a huge deal to do this, but it will result in recompiles on the procedure since the execution plan for an UPDATE and one for an INSERT are...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 7:23 am
TRY/CATCH won't help performance, but it will make your code easier to write & maintain.
Can you post an execution plan? If possible, the actual execution plan not the estimated one.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 6:56 am
Paul DB (9/10/2008)
Steve Jones - Editor (9/9/2008)
Why not just use the SELECT UNIONS instead of the temp tables in the select? It appears that you're using static values in there.
I...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 6:34 am
There is so much code missing from this query, it's hard to see where you're going wrong. First, using sp_executesql is for working with dynamic TSQL. Nothing in this query...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 6:30 am
This is psuedo-code, but something along these lines:
CREATE TABLE #MyIDs
(ID int)
INSERT INTO TableA
(...)
OUTPUT INSERTED.ID
INTO #MyIDs
SELECT ...
FROM TableB
Then you can obviously do what you want with the temporary table. use...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 6:25 am
I'm not a RAID expert, but having seperate file groups on different drives will be faster than all the filegroups on one drive, yes.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 6:11 am
Or, rather than hard coding all those values in a query, create a table and store them there. It'll sure make maintenance easier.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 6:09 am
Can you break it down and run a couple of steps at a time? I tried duplicating the script in miniature and it worked fine.
CREATE TABLE x ( id INT,...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 6:07 am
Another vote for using the OUTPUT clause. That's incredibly useful for doing exactly what you're asking for.
Also, I wouldn't recommend using @@IDENTITY. @@IDENTITY is not limited by the scope of...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 5:31 am
GilaMonster (9/10/2008)
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 10, 2008 at 5:18 am
Ah, that's a shortcoming with the tool, not SQL Server. Ummm, you might try associating to the first column and then renaming the association (not sure how to do that)...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 9, 2008 at 12:55 pm
I'd start by attempting to kill the process. That should initiate a rollback, meaning whatever changes that process had been making will go away, but you shouldn't have problems with...
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 9, 2008 at 12:17 pm
The best description of this I've seen is contained in the first two chapters of Itzik Ben-Gan's book, Inside SQL Server 2005: T-SQL Querying.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 9, 2008 at 12:15 pm
If I understand the question, you simply add the relationship three different times, relating the lookup value to the three different columns individually. It's a fine method.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 9, 2008 at 12:13 pm
Hooey.
If it's a reporting system, and only a reporting system, you should mark the database itself as read only.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 9, 2008 at 12:03 pm
Viewing 15 posts - 19,606 through 19,620 (of 22,219 total)