Forum Replies Created

Viewing 15 posts - 16 through 30 (of 65 total)

  • RE: Running total with a twist

    Doh, of course, recursive CTE! Thanks!
    I added some more testdata and rewrote your code to work with it 

    CREATE TABLE #t_customers (cust_id INT...

  • RE: How to match replay results with trace file?

    Can't you see it in the GUI? The rows with errors are displayed in red with a Replay Provider Error
    I tested a replay myself, and error seems to get EventClass 63485...

  • RE: Running total with a twist

    Sorry about that:

    CREATE TABLE #t_customers (cust_id INT PRIMARY KEY, limit NUMERIC(19, 2))
    CREATE TABLE #t_orders (cust_id INT, order_no INT PRIMARY KEY, tot_value NUMERIC(19, 2))

  • RE: CASE Statement against TEMP table is failing

    Probably an SQL Server bug, no "regular" queries should raise that error, if you don't find it in microsoft connect, you should try to recreate with some sample data and...

  • RE: GETDEFAULT function, how to use?

    Thanks guys, very interesting, this function seem to be performed during compilation time and evaluation is inserted inline, or something like that.
    Because it's not possible to call with variables.

  • RE: Self-locking process (that access tempdb)

    Hi!

    I have a process that deadlocks on itself. It also locks some important tables, so other normal processes are blocked when reading these tables.

    But I don't know how to "undeadlock"...

  • RE: Self-locking process (that access tempdb)

    Yeah unfortunately these routines are complex and in abundance :/

    But, do you know how to resolve "self-deadlocks" so they don't lock everything else out?

  • RE: Trying to export FOR XML procedure using BCP - getting files padded with spaces

    Ok, finally found a workaround 😎

    You do this first thing in your SP:

    -- IF 1 = 0 will trick FMTONLY to process the first SELECT and get correct "datatype" of...

  • RE: help left join

    Not in the specific case where you're only looking to pull rows that did not find a match: by definition that won't duplicate any data, since no rows will match....

  • RE: Using a Date compariason in a Case statement

    You can't have CASE [LastHireDate] WHEN boolean_expression THEN X

    Only: CASE [LastHireDate] WHEN value_expression THEN x

    Change your case to just:

    CASE

    When YEAR([LastHireDate]) < Year(@EndYearlyDate) then '12'

    When Month([LastHireDate]) = '1' then '12'

    When...

  • RE: Cross Apply error

    Ok, what about this query?

    SELECT compatibility_level FROM sys.databases WHERE database_id = DB_ID()

    It's not that you have compatibility 80 (sql server 2000)?

  • RE: Insert subset of self-referencing table into that table

    You should add those requirements into your question then 🙂

    What about this one? More complex but i couldn't find anything better either

    ;WITH CTE AS (

    SELECTROW_NUMBER() OVER(ORDER BY nRow_id) + maxid...

  • RE: help left join

    If you want to test for existance / non-existances I think EXISTS is better than LEFT JOIN, since it's more clear what you're doing and LEFT JOIN can at least...

  • RE: Insert subset of self-referencing table into that table

    Well, this is one (bad?) way to do it:

    INSERT INTO tTable (nParent_id, cGroup, cValue)

    SELECTx.nParent_Id + y.maxid , 'Two', cValue

    FROMtTable x

    CROSS APPLY (

    SELECTMAX(NRow_id) AS maxid

    FROMtTable

    ) y

    WHEREx.cGroup = 'One'

    ORDER BY x.nRow_Id

  • RE: Cross Apply error

    Check SELECT @@VERSION

    It can be you're using some old SQL Server, alternatively, you might need to alias that function call ie:

    select *

    FROM dbo.Registos r

    CROSS APPLY dbo.fnObtemCategoriaAviacao(r.PaisOrigem, r.PaisDestino) x

    For me the...

Viewing 15 posts - 16 through 30 (of 65 total)