Viewing 15 posts - 1,321 through 1,335 (of 1,492 total)
BOL gives good documentation on locking. In brief it appears you were confused between the lock granularity, ROWLOCK, PAGLOCK, TABLOCK etc and the lock type, shared, UPDLOCK, XLOCK etc.
In your...
January 31, 2007 at 7:05 am
For code like this to work you need to use UPDLOCK, or XLOCK, and have an index...
January 30, 2007 at 9:41 am
Something along the lines of the following should work:
SELECT Y.*
FROM YourTable Y
JOIN (
SELECT Y1.[ID], MAX(Y1.PAT_TO_DATE) AS PAT_TO_DATE
FROM YourTable Y1
GROUP BY Y1.[ID]) D
ON Y.[ID] = D.[ID] AND Y.PAT_TO_DATE = D.PAT_TO_DATE
January 26, 2007 at 8:16 am
The question is not very clear.
If there are not too many rows (less that 10,000?) something like the following triangular join may
be what you want. With a lot of rows...
January 25, 2007 at 10:06 am
A trigger should work although it would probably be more efficient to code the logic when you INSERT or UPDATE. If you want to use a trigger, something like the...
January 23, 2007 at 10:03 am
This may work. It uses derived tables, only one column in the GROUP BY
and an EXISTS subquery to avoid the overhead of a DISTINCT.
SELECT ISNULL(D.PCCount, 0) AS PCCount
,P.Postcode, P.Town,...
January 23, 2007 at 8:08 am
Assumming UkPostcodes.Postcode contains the postcode district and Customers_Trade.Postcode
contains the full postcode, how about:
SELECT ISNULL(D.PCCount, 0) AS PCCount
,P.* -- or whatever columns you want
FROM dbo.UkPostcodes P
LEFT JOIN (
SELECT P1.Postcode
,COUNT(*) AS PCCount
FROM...
January 22, 2007 at 9:28 am
It is difficult to tell what you want and which columns are meant to match. In future please follow the instructions at http://www.aspfaq.com/etiquette.asp?id=5006
You may want to do something like...
December 13, 2006 at 8:35 am
'Won"t Fix' should be 'Won''t Fix'
ie Embed two single quotes, not one double quote.
eg SELECT 'Won''t Fix' AS STRING
STRING
---------
Won't Fix
(1 row(s) affected)
December 8, 2006 at 5:13 am
Unfortunately ROUND is a lot worse than FLOOR as six month ranges fail to show correctly.
dob DateFrom DateTo RoundAge CaseAge
-------- ------------ --------- -------- -------
19460624 19461224 19470623 1 0
19460624 19471224 19480623 ...
December 7, 2006 at 8:51 am
Use the REPLACE function. Something like:
SELECT *
FROM TableA A
JOIN TableB B ON A.PK = B.PK
WHERE REPLACE(REPLACE(A.ColWithCRLF, CHAR(13), ''), CHAR(10), '') <> B.ColWithoutCRLF
December 6, 2006 at 12:09 pm
Floor nearly works but it produces a rounding error every 4 years as below:
dob Birthday FloorAge CaseAge RoundingError
-------- -------- ----------- ----------- -------------
19460624 19460624 0 0 N
19460624 19470624 0 1 ...
December 6, 2006 at 8:13 am
Kenneth,
Nice use of modulus but your age calculation is wrong.
eg. A child will come out as 1 year old when he/she is one day old.
Looking back in this thread, my...
December 6, 2006 at 6:22 am
sp_execute and sp_executesql are not the same thing.
sp_execute is used with prepared statements by client APIs. (ODBC, ADO.NET etc)
sp_executesql is used by tsql for dynamic queries.
December 5, 2006 at 11:16 am
Viewing 15 posts - 1,321 through 1,335 (of 1,492 total)