I am attempting to troubleshoot a slow running stored procedure in SQL Server 2005. I am analyzing the execution plan and see a SORT that is 45%, but I am not using an ORDER clauses. What would be causing this.
UPDATE SP (cleaned up, and made change on OR's)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Rp...
I am attempting to tune some stored procedures and have a question on indexes. I have used the tuning advisor and they recommended two indexes, both for the same table. The issue is one index is for one column and the other is for multiple columns, of which it includes the same column from the first. My question is why and what is the di...
There is the following code:
declare @XmlData xml =
'<Locations>
<Location rid="1"/>
</Locations>'
declare @LocationList table (RID char(32));
insert into @LocationList(RID)
select Location.RID.value('@rid','CHAR(32)')
from @XmlData.nodes('/Locations/Location') Location(RID)
insert into @LocationList(RID)
select A2RID from tblCdbA2
...
Consider following piece of code:
declare @var bit = 0
select * from tableA as A
where
1=
(case when @var = 0 then 1
when exists(select null from tableB as B where A.id=B.id)
then 1
else 0
end)
Since variable @var is set to 0, then the result of evaluating searched case operator is 1. In the documentation of case i...