Viewing 15 posts - 976 through 990 (of 1,494 total)
According to relational theory a table is an unordered set.
This means that the order of rows outside the ORDER BY clause cannot be guaranteed.
If you want rows returned in the...
June 25, 2009 at 9:21 am
or:
SELECT t
FROM @t
ORDER BY CASE t WHEN 'O' THEN 1 ELSE 0 END, t
June 24, 2009 at 6:04 am
If you can upgrade to SQL2008, the following may be worth looking at as an alternative to XML.
http://www.sqlservercentral.com/articles/SQL+Server+2008/66554/
It looked like an interesting idea but I have not yet got around...
June 11, 2009 at 10:20 am
Brain dead today - it can, of course, all be done with integers. Still only one read of the table:
SELECT D.Range
,CASE N.N
WHEN 1
THEN MinYearMonthofValue / 100
ELSE MaxYearMonthofValue / 100
END AS...
June 11, 2009 at 6:43 am
You could also combine the Year and Month either as a float, as below, or as a datetime:
SELECT D.Range
,CASE N.N
WHEN 1
THEN FLOOR(MinYearMonthofValue)
ELSE FLOOR(MaxYearMonthofValue)
END AS YearofValue
,CASE N.N
WHEN 1
THEN CAST((MinYearMonthofValue * 100)...
June 11, 2009 at 6:07 am
If you can upgrade to SQL2008, you may want to review this recent article:
http://www.sqlservercentral.com/articles/SQL+Server+2008/66554/
June 4, 2009 at 9:10 am
INSERT INTO PersonalInfo (firstname, secondname, nationalDno)
SELECT DISTINCT firstname, secondname, nationalDno
FROM StagingTable S
WHERE NOT EXISTS
(
SELECT *
FROM PersonalInfo P
WHERE S.firstname = P.fistname
AND S.secondname = P.secondname
AND S.nationalDno = P.nationalDno
)
June 3, 2009 at 4:43 am
Jeff Moden wrote an article which covered this.
(Whether you want to rely on non-relational features is up to you.)
http://www.sqlservercentral.com/articles/Advanced+Querying/61716/
If there are not too many trdates for each cusip, I would...
May 7, 2009 at 10:16 am
The fundamental problem with the original query is the JOIN in the subquery. (These always seem to end up as nested loops which is rarely a good idea.)
You should avoid...
May 6, 2009 at 5:08 am
May something like the following although this will also produce John running:
SELECT *
FROM
(
SELECT P1.[name], A1.activity, COUNT(*) AS CatCount
FROM person P1
JOIN activity A1
ON P1.catid1 = A1.catid1
AND P1.catid2 = A1.catid2
GROUP BY P1.[name],...
April 29, 2009 at 2:54 am
UPDATE table1
SET seq =
(
SELECT T3.seq
FROM table3 T3
WHERE EXISTS
(
SELECT *
FROM table2 T2
WHERE T2.mi_class_name = T3.mi_class_name
AND T2.obj_num = table1.obj_num
AND T2.[name] = table1.[name]
)
)
WHERE EXISTS
(
SELECT *
FROM table3 T31
WHERE EXISTS
(
SELECT *
FROM table2 T21
WHERE T21.mi_class_name =...
April 29, 2009 at 2:37 am
Chirag (4/3/2009)
WHERE rt.location_id = 2
I think this will take out the NULLs in rt
April 3, 2009 at 4:15 am
Try:
FROM ttc_room r
CROSS JOIN ttc_event_date_list edl
LEFT JOIN ttc_room_tracker rt
ON edl.date_list = rt.event_date
AND r.room_id = rt.room_id
AND rt.location_id = 2
WHERE r.location_id = 2
AND edl.date_list BETWEEN '20090402' AND '20090409'
April 3, 2009 at 3:50 am
While not available in SQL2000, the INTERSECT and EXCEPT operators compare NULLs as being equal even with ANSI_NULLS on.
April 2, 2009 at 3:11 am
Viewing 15 posts - 976 through 990 (of 1,494 total)