Viewing 15 posts - 1,036 through 1,050 (of 1,491 total)
In the data you have provided the OrderId looks as though it may contain a 2 digit year.
If this is the case then something like the following may work:
ORDER BY
    CASE
        WHEN...
January 13, 2009 at 8:49 am
Strange Syntax.
SQL2000 seems to ignore the SET as does SQL2005 against a version 80 db.
January 13, 2009 at 7:49 am
Use CASE. MAX will ignore the NULLs. eg:
SELECT YourId
    ,MAX(CASE WHEN othertable.field > 4 THEN YourDate END)
    ...
January 13, 2009 at 7:41 am
Try something like:
SELECT T1.[Order], T1.OpNo, T1.Operation
    ,DENSE_RANK() OVER (ORDER BY T1.[Order], MAX(T2.OpNo)) AS GroupID
FROM YourTable T1
    JOIN YourTable T2
        ON T2.Operation = 'SETG'
            AND T1.[Order] = T2.[Order]
            AND T1.OpNo >= T2.OpNo
GROUP BY T1.[Order], T1.OpNo, T1.Operation
January 13, 2009 at 5:04 am
Or you could have the hour as a datetime to cope with multiple days. Something like:
SELECT D.HourStart
    ,SUM
    (
        CASE
            WHEN D.HourStart >= S.StartTime AND D.HourEnd < S.EndTime
            THEN 60
            WHEN D.HourStart < S.StartTime AND D.HourEnd...
January 8, 2009 at 9:46 am
Try looking up 'Concurrency Control' in the SQL2000 Books Online.
January 8, 2009 at 5:08 am
It does not make a great deal of sense, but, for the given data, something like the following should work:
SELECT D1.A, D1.B, D1.C, D2.D
FROM
(
    SELECT ROW_NUMBER() OVER (PARTITION BY A ORDER...
January 5, 2009 at 5:02 am
The syntax is wrong. Try:
SELECT @BuildID = BuildID ...
November 28, 2008 at 4:23 am
The second query may produce a lot of duplicate rows in tblFOO.
Also, joins in subqueries always seem to be done with nested loops which is rarely efficient.
(Derived tables are fine.)
If...
November 20, 2008 at 2:58 am
Already answer - something wrong with my connection today.
November 19, 2008 at 4:20 am
Opps - already answered
November 19, 2008 at 4:19 am
The variable @VField_SP needs to be incorporated into the dynamic select.
It will not work as a parameter. Something like:
DECLARE @VField_SP nvarchar(300)
    ,@VLKL_LSD_ID int
    ,@PResult varchar(300)
    ,@SQLString nvarchar(4000)
SELECT @VField_SP = 'LKL_DOCUMENT_NR'
    ,@VLKL_LSD_ID = 45464
SET...
November 14, 2008 at 3:12 am
Maybe something like:
SELECT A.AccountNumber
    ,A.CustomerName
    ,D.subtotal14 + D.vat14 - D.Payment14 AS [InvoiceBalance(0-14 Days)]
    ,D.subtotal31 + D.vat31 - D.Payment31 AS [InvoiceBalance(15-31 Days)]
FROM Accounts A
    JOIN
    (
        SELECT S.AccountID
            ,ISNULL(SUM(CASE WHEN S.dateandtime >= DT.DT14 THEN S.subtotal END), 0) AS...
November 12, 2008 at 9:01 am
You could try checking your SP for #temp tables and table variables. If you are using these then adding COLLATE DATABASE_DEFAULT to the definitions of string columns may solved your...
November 12, 2008 at 4:01 am
Maybe:
DECLARE @TempTbl TABLE
(
    Col1 char(7)
    ,Col2 char(7)
    ,Col3 char(7)
    ,Case_Col bigint
)
INSERT INTO @TempTbl
SELECT Col1, Col2, Col3, MIN(Case_Col)
FROM tbleActualDBTable
WHERE Case_Col > 0
GROUP BY Col1, Col2, Col3
HAVING COUNT(Case_Col) > 1
otherwise post some sample data with...
November 12, 2008 at 2:58 am
Viewing 15 posts - 1,036 through 1,050 (of 1,491 total)