Forum Replies Created

Viewing 15 posts - 3,091 through 3,105 (of 4,085 total)

  • RE: Update sortorder column to +1

    You're better off using a CTE than the CROSS APPLY.

    WITH ActiveUpdates AS (

    SELECT [ID], SortOrder, isActive, ROW_NUMBER() OVER( ORDER BY SortOrder DESC, [ID] ) - 1 AS rn

    FROM @CustomerConditions

    )

    UPDATE ActiveUpdates

    SET...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: NULL, = NULL and IS NULL

    dan-572483 (8/1/2012)


    Interesting... I've always used "<value> IS NULL" having learned T-SQL from an application I supported. Using the default configuration "<value> = NULL" doesn't genertate an...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Insert with sp_ExecuteSql

    mandoswork (8/1/2012)


    The normalisation is the whole point of the exercise. I'm trying to import a flat file, with the same columns repeated 10 times, into a more logical structure -...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Group by?

    A GROUP BY with CASE expressions is likely to perform better, because it requires fewer scans and logical reads of the base table.

    SELECT Sales_CustomerID

    FROM @sales1

    GROUP BY Sales_CustomerID

    HAVING COUNT(CASE WHEN Sales_Status...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Group By Help

    JayWinter (7/31/2012)


    I did remove the GROUP BY and and achieved the correct result. My original post shows a 2nd script without GROUP BY.

    Your DISTINCT clause is hiding the problem. ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Pivot: Need some more eyes...

    You're looking for tables name AuditRecCount, DocumentRecCount, and FileRecCount, but the tables are named AuditRecord, Document, and File respectively. Since the names don't match, there are no values to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Production issue with varchar(max)

    SSMS doesn't display the entire field. I think that it only displays 255 characters by default. If you are trying to view the contents of the variable in...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Sum DISTINCT fields only

    No, the DISTINCT masks the problem with the join creating false "duplicates" in the sum. The GROUP BY only masks this same problem in a different way. The...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Data Delete issue

    Reddy Ksr (6/26/2012)


    Deleting the records by joining more than one table is not possible.

    for example:

    delete from EMP inner join dept

    on emp.deptno=dept.deptno and dept.deptno=50

    error:

    Incorrect syntax near the keyword 'inner'.

    thanks,

    kumar

    Actually, it is....

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Sum DISTINCT fields only

    I don't think that using DISTINCT is the correct way to solve this problem. DISTINCT will ignore ALL duplicate values, not just the ones caused by your join. ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Finding a future date in a calendar

    Lowell posted his script, so I don't need to find a link. I think his calculation for Julian Day can be simplified to DATEPART(dy, YourDateField), but you need an...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Finding a future date in a calendar

    I don't think that your sample values are correct. June 22, 2012 is 102 days after Feb 3, 2012. If you only want to count paid days, are...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Unexpected results when I Join, use View or Cross Apply - mysterious

    brosspaxedi (6/21/2012)


    I'm not sure why you couldn't open the image. It is a .png, which might not be supported by your browser.

    The site is blocked by my company.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Unexpected results when I Join, use View or Cross Apply - mysterious

    First, I can't access that link. Second, a picture is not a useful way to post code, because we can't copy and paste it into SSMS to test it....

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Sum of sums?

    You could probably use the windowing functions with the SUM to get the desired output, but I've found that the windowing functions are not terribly efficient, so you're probably better...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 3,091 through 3,105 (of 4,085 total)