Forum Replies Created

Viewing 15 posts - 2,911 through 2,925 (of 4,087 total)

  • RE: Pivot help please?

    kiril.lazarov.77 (10/15/2015)


    I could pivot salesprice but not both salesprice and quantity. Is it possible? thanks

    Not with one pivot, but there is nothing to stop you from using two pivots. ...

  • RE: Cross Apply

    g.britton (10/15/2015)


    The supposedly correct answer "The TOP 3 selling products for all customers who have made a purchase." is ambiguous. As I read it, I would expect only three...

  • RE: Sorting working differently after moving from SQL Server 2008 to 2012

    Kristen-173977 (10/9/2015)


    Personally I'm not keen on that sort of workaround (or the "-1" for the EmpLogin for that matter) such things tend to have side effects and/or break sooner or...

  • RE: Sorting working differently after moving from SQL Server 2008 to 2012

    Kristen-173977 (10/9/2015)


    Assuming the "Please select" needs to be the first entry? then the ORDER BY needs to perhaps be:

    ORDER BY

    CASE WHEN EmpLogin = '-1' THEN...

  • RE: multi-part identifier could not be bound

    You have a main query, a subquery, and a sub-subquery. The table adminfee is only specified within the sub-subquery, but you are trying to reference it in the main...

  • RE: Need help with a simple query from a one to many table relation.

    ScottPletcher (10/7/2015)


    Interesting. Are you sure you don't have those stats backwards? The NOT EXISTS must check the entire table every time to verify that a given row does...

  • RE: Need help putting data into XML format

    Your original query was very close. You're getting Element2 and Element3 twice, because you're specifying them both twice: once in the path() and once in the alias. Instead of...

  • RE: Updating statment depending on 2 fields

    I think this is what you are looking for:

    refkey = STUFF(

    CASE

    WHEN st.base <> '' and st.qttbase <> 0

    THEN ',B'

    ELSE ''

    END +

    CASE

    WHEN st.cos <>'' and st.qttcos <> 0

    THEN ',C'

    ELSE ''

    END +

    CASE

    WHEN...

  • RE: Free form text parsing suggestions

    ScottPletcher (9/30/2015)


    Yikes. Here's an alternative that should perform better for you:

    Part of the reason that XML string splitters are inefficient is converting character separated strings to a format that...

  • RE: Free form text parsing suggestions

    HTML is a subset of XML, it's probably more efficient to treat it as XML and use xquery.

    Drew

  • RE: Union Stored Procedure

    UNION applies to sets and stored procedures are not sets, although they may return sets. If you want to union the results of two stored procedure calls, you'll need...

  • RE: UPDATE Multiple columns in a CTE

    Since CTEs are essentially single-use views, they follow the same rules as updatable views; specifically

    CREATE VIEW (Transact-SQL)

    Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one...

  • RE: Counting number of occurances

    Perhaps I'm missing something, but if you want to look specifically at the second ticket, then COUNT is the wrong aggregate. Try the following.

    WITH Ticket_Number AS (

    SELECT ti.person_ID, ticket_date,...

  • RE: UPDATE using table alias

    I dislike the consistent "U" as a table alias for the table being updated for some of the same reasons that I dislike sequential table aliases, the most important one...

  • RE: Painful datetime conversion

    Try the FORMAT function. It was added in SQL 2012.

    SELECT FORMAT(vhrgdt, '0000-00-00') + ' ' + FORMAT(vhrgtm, '00:00:00.000'), *

    FROM #Something s

    Drew

Viewing 15 posts - 2,911 through 2,925 (of 4,087 total)