Viewing 15 posts - 691 through 705 (of 2,171 total)
See http://www.sqlteam.com/article/datediff-function-demystified
DECLARE@Sample TABLE
(
polnum int,
startdate datetime,
enddate datetime,
policyholder varchar(200),
policy varchar(200)
)
Set dateformat dmy
INSERT@Sample
SELECT1000012, '01/01/2008', '31/12/2008', 'Joe bloggs', 'CycleIns' UNION ALL
SELECT1000013, '12/08/2008', '17/08/2008', 'Dave Smith', 'TravelIns'...
September 24, 2008 at 2:49 am
Are you sure the @SystemUser variable gets set?
September 24, 2008 at 2:45 am
SELECTSUM(CASE WHEN CONVERT(CHAR(8), Col1, 114) >= '07:30:00' AND CONVERT(CHAR(8), Col1, 114) < '16:00:00' THEN 1 ELSE 0 END) AS [7:30am to 4pm],
SUM(CASE WHEN CONVERT(CHAR(8), Col1, 114) >= '16:00:00' AND CONVERT(CHAR(8),...
September 22, 2008 at 8:13 am
LEFT JOIN(
SELECTPartyID,
MAX(CASE WHEN QuestionID = 13 THEN Col1 ELSE NULL END) AS sd13,
MAX(CASE WHEN QuestionID = 15 THEN Col1 ELSE NULL END) AS sd15,
MAX(CASE WHEN QuestionID = 16 THEN Col1...
September 17, 2008 at 2:50 am
Here is a CURSOR solution that scales excellent.
10 times the sample data, 10 times the time.
SET NOCOUNT ON
CREATE TABLE#Source
(
RowID INT PRIMARY KEY CLUSTERED,
RowKey INT,
Locale VARCHAR(10)
)
INSERT#Source
SELECT 1, 5, 'en' UNION ALL
SELECT...
September 16, 2008 at 7:00 am
ALTER proc dbo.getMaxval
(
@AllocId bigint,
@Cnt int output
)
as
set nocount on
select@cnt = max(cnt)
fromAllocationVisit
whereAllocId = @AllocId
set @cnt = coalesce(@cnt, 0) + 1
September 16, 2008 at 12:23 am
I hope you meant
SELECT FromLocation AS theLocation FROM tablename
UNION
SELECT ToLocation FROM tablename
September 15, 2008 at 5:04 am
SELECTCol,
Col2,
Col3,
Col4,
Col5
FROM(
SELECTCol,
Col2,
Col3,
Col4,
Col5,
ROW_NUMBER() OVER (PARTITION BY Col1, Col2 ORDER BY Col3 DESC) AS RecID
FROMTable1
) AS d
WHERERecID = 1
September 15, 2008 at 4:07 am
There can be a number of reasons for this query to go slow.
Check out execution plans. See if there is some parallellism gone bad on x64 server.
September 14, 2008 at 7:36 am
DECLARE@Sample TABLE
(
ID BIGINT
)
INSERT@Sample
SELECT3202306000 UNION ALL
SELECT3202307500 UNION ALL
SELECT3202307503
SELECT DISTINCTs.ID,
s.ID + x.Number AS Yak
FROM@Sample AS s
CROSS JOIN(
SELECT0 AS Number UNION ALL
SELECT1 UNION ALL
SELECT2 UNION ALL
SELECT3 UNION ALL
SELECT4
) AS x
September 12, 2008 at 3:32 pm
September 12, 2008 at 3:25 pm
Then you were wrong this time, I am sorry to say.
Read the query.
September 9, 2008 at 8:18 am
Because you want to filter out ALL records for same coID group if ANY of the records has an mCT = 'Y' value.
September 9, 2008 at 1:32 am
http://www.sqlmag.com/Article/ArticleID/92888/sql_server_92888.html
Itzik Ben-Gan
Creating a clustered index on a table does not guarantee that the
data is stored in the file in index key order. Data movement caused
by page splits, changing...
September 6, 2008 at 9:01 am
Viewing 15 posts - 691 through 705 (of 2,171 total)