Forum Replies Created

Viewing 15 posts - 2,431 through 2,445 (of 4,087 total)

  • RE: Converting a XML datatype to varchar(max).

    Yes, use a different approach. Either shred the XML and make your adjustments on the shredded data or use .modify() to modify your XML.

    Since you haven't provided sample data...

  • RE: get the price of last buy of each sell

    Why aren't the last buys from 2016-08-18 17:38:40.000 and 2016-08-17 15:03:52.000?

    Drew

  • RE: Check if both fields from table B are in table A

    Francis Twomey (8/22/2016)


    Thanks for the responses. Here is my code currently:

    INSERT INTO item_relation_table

    (parent__id,

    child__id,

    relation)

    SELECT xm.1_id, xm.2_ID,

    'A',

    from tablexm xm

    where xm.1_id != xm.2_ID and

    exists(select 1 from item ip WHERE ip.mfg =...

  • RE: Need Guidance On Query

    Depending on what your statuses are, you may not even need a case expression. If your only statuses are ADD and DISCHARGE, then you can just use MAX(status) <...

  • RE: Need Guidance On Query

    Jacob Wilkins (8/22/2016)


    drew.allen (8/22/2016)


    COUNT will work as an aggregate if you return a NULL in the proper cases. COUNT() may not perform the best, but it will work.

    COUNT(CASE WHEN...

  • RE: Need Guidance On Query

    COUNT will work as an aggregate if you return a NULL in the proper cases. COUNT() may not perform the best, but it will work.

    COUNT(CASE WHEN status='Discharge' THEN 1...

  • RE: Check if both fields from table B are in table A

    You should post what you've already tried. It's going to be easier for you to understand if it's just a minor change in your existing code rather than having...

  • RE: stored procedure issue

    Jacob Wilkins (8/22/2016)


    Something like this:

    [column] LIKE '['+@a+'-'+@b+']%'

    Cheers!

    This will only work if you pass in single characters as your parameters. Given that you've defined your parameters as VARCHAR(50), it seems...

  • RE: stored procedure issue

    And if you're looking for a range of values between the two parameters, it becomes a bit tricky. For instance, if your parameter values are 'A' and 'C', you'll...

  • RE: Are the posted questions getting worse?

    WayneS (8/22/2016)


    drew.allen (8/17/2016)


    I'm writing an article explaining my solution to Credits and Debits and am looking for two or three people to review it before I submit it. Any...

  • RE: Re-ordering a Sequence

    mister.magoo (8/21/2016)


    How is this not just a simple update/cte?

    WITH CTE AS

    (

    SELECT

    seq

    , ROW_NUMBER() OVER

    (

    ...

  • RE: Selective updates to NULL

    This will also work.

    UPDATE #test

    SET Flag = @Flag

    WHERE Id = @Id

    AND COALESCE(Flag, ~@Flag, 0) <> COALESCE(@Flag,...

  • RE: Selective updates to NULL

    ChrisM@Work (8/19/2016)


    Why can't you use this, Phil (substituting "peanut" for an appropriate integer value):

    UPDATE #test

    SET Flag = @Flag

    WHERE Id =...

  • RE: Selective updates to NULL

    I like the following method, particularly when you are comparing multiple columns.

    UPDATE #test

    SET Flag = @Flag

    CROSS APPLY (

    SELECT Flag

    ...

  • RE: WHERE clause problem comparing 2 float values

    This is even in the Microsoft documentation.

    Using decimal, float, and real Data


    Avoid using float or real columns in WHERE clause search conditions, especially the = and <> operators. It is...

Viewing 15 posts - 2,431 through 2,445 (of 4,087 total)