Forum Replies Created

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

  • RE: Update sortorder column to +1

    kaushal_shah26 (8/2/2012)


    I googled the syntax and changed the query to include partition and also pull only records where isactive =1. The reason for pulling only isactive = 1 is we...

  • RE: Update sortorder column to +1

    kaushal_shah26 (8/2/2012)


    Thanks for the code. It works for the sample code. Now, How do we do this for all types. In the sample code, we only have one type which...

  • 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...

  • 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...

  • 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 -...

  • 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...

  • 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. ...

  • 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...

  • 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...

  • 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...

  • 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....

  • 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. ...

  • 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...

  • 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...

  • 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

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