Forum Replies Created

Viewing 15 posts - 106 through 120 (of 1,957 total)

  • RE: Find Latest Date from Multiple Columns

    For those interest, here is the CASE query actual execution plan, where the optimiser has swapped out the CASE statement for the COMPUTED columns automatically.

  • RE: Find Latest Date from Multiple Columns

    Eirikur Eiriksson (1/19/2016)


    Jacob Wilkins (1/19/2016)


    Throwing in the CASE using Eirikur's wonderful setup yielded this on one million rows on my machine (tangentially, I'm embarrassed that Eirikur's laptop is faster than...

  • RE: Find Latest Date from Multiple Columns

    Thanks for testing Orlando.

    I wonder how the performance of each method will depend on how many "date columns" are present as well, whether having 20 columns vs 10 columns is...

  • RE: organize xml query output

    You are probably best off using FOR XML PATH for this in my opinion.

    Select

    -- Make IdDoc an Attribute by prefixing with @

    R.IdDoc [@IdDoc]

    ...

  • RE: Find Latest Date from Multiple Columns

    Just noticed "and the column header it belongs to", so:

    SELECT MA.MaxDate, MA.ColName

    FROM <mytable> AS MT

    CROSS APPLY (

    SELECT TOP(1) VA.LName, VA.LDate

    FROM (VALUES('L1',MT.L1),('L2',MT.L2),('L3',MT.L3)....) VA(LName, LDate)

    ORDER BY...

  • RE: Find Latest Date from Multiple Columns

    You can also use APPLY

    SELECT MA.MaxDate

    FROM <mytable> AS MT

    CROSS APPLY (

    SELECT MAX(VA.LDate)

    FROM (VALUES(MT.L1),(MT.L2),(MT.L3)....) VA(LDate)

    ) AS MA(MaxDate)

    Excuse any slight syntax errors, I have typed this away from...

  • RE: Performance issue when returning zero records

    Don't get confused into thinking that a CTE materialises the query inside it, it is just a query format structure and what you have there is a horrible mess.

    I...

  • RE: the use of CTEs

    Jeff Moden (1/8/2016)


    Hugo Kornelis (1/8/2016)


    Jeff Moden (1/7/2016)


    Alan.B (1/6/2016)


    You can't write a recursive CTE with using pre-CTE features.

    Technically correct because only an rCTE can be an rCTE but the rather...

  • RE: Header and Detail Data

    No matter which output route you take, why not simply create a set with

    key (order id?)

    line (order line number/row_number())

    data (nvarchar(max) fixed width data)

    Insert the headers, all with [line] =...

  • RE: SSMS: First connection to DBMS takes over 15 minutes

    You could try running SSMS with the /log switch.

    This will write a log to your local user profile under %AppData%\Microsoft\AppEnv\10.0 called ActivityLog.xml

    If you save the attached XSL file in the...

  • RE: Can't find hidden field

    NineIron (12/24/2015)


    I'm using Report Builder and don't see any dropdowns or how to open in xml.

    Instead of opening the report in report builder, download the rdl and open it with...

  • RE: Can't find hidden field

    Try the dropdown list at the top of the properties window.

    If that fails, open the report xml and search for it there.

  • RE: DBA Tasks - To automate or use my own eyes

    We use an SSRS "dashboard" for this, also an overnight SSRS report which lists any individual job step errors.

    These are based on querying the agent logs in msdb.

  • RE: How to dynamically create 12 rows per customer in a SQL Table

    pete.ciskanik (12/17/2015)


    I have a staging table of customer names, numbers, and sales data etc. I've been trying to write a stored procedure that inserts everything into that staging table. One...

  • RE: Has anyone seen T-SQ like this (A space after the tablie alias and before the column name

    YSLGuru (12/14/2015)


    SELECT T. Col1, T.col2

    FROM TABLE T

    WHERE 1 = 1

    There is a space after T. and before Col1 without the use of brackets and yet this works for some reason....

Viewing 15 posts - 106 through 120 (of 1,957 total)