Forum Replies Created

Viewing 15 posts - 406 through 420 (of 4,085 total)

  • Reply To: how to call same logic using different parameter in if then else stored procedur

    You do realize that the IF and the ELSE section are EXACTLY THE SAME, right?  One definition of insanity is doing the same thing and expecting different results.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Remove first comma from stuff

    rVadim wrote:

    Can't you use RIGHT or SUBSTRING ?

    You can use RIGHT() or SUBSTRING(), but both of those tend to be more complex than STUFF().

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Remove first comma from stuff

    Papil wrote:

    Hi,

    I am doing STUFF in my query which is concatenating the blank data too and data looks like below. Sometimes there is space+comma and sometimes only comma in the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: XML Data singleton value not fixed????

    You would use a CROSS APPLY or OUTER APPLY like any other table-valued function.

    FROM data.dbo.CalendarEvents AS ce
    INNER JOIN data.dbo.ObjectMetadata AS OM2
    ON ce.ParentObject = OM2.ObjectID
    INNER...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Which items can be built (do we have enough product for)?

    Steve Jones - SSC Editor wrote:

    Maybe Drew will chime in. He comes up with some great creative SQL solutions.

    I would need some data and expected results to work with.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Using a CTE in a subquery

    Also, get rid of the DISTINCTUNION already does a distinct, so specifying DISTINCT here just clutters up your code with no benefit.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: How do append to date value?

    ciss1 wrote:

    Hey Drew,

    Which part of the query is static, I am curious?

    If you referring to the last query I posted, that's the printed version after I did PRINT @query.

    I don't...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: How do append to date value?

    The problem you are seeing is that you made a dynamic part of your query static.  Specifically, the 'Year_' + CONVERT(NCHAR(4), YEAR(eventyear)) needs to be dynamic so that when you...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Getting a result set from temp tables

    tjolliffe's approach requires two scans of each of the tables.  The following only uses one scan of each of the tables, but you may be better off just skipping the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: How do append to date value?

    Michael L John wrote:

    It's embedded.  You need to ADD quotes, not take them away

    ''YEAR_'' + CONVERT(nvarchar(8), YEAR(eventyear)) eventyear,

    Before you execute the dynamic SQL, print it.

    PRINT @query

    Run that query, fix the issues, and...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Date & Time Difference

    DATE/TIME data should be stored in DATE/TIME fields.  If they are stored in any other format, you should consider changing that.

    DATE/TIME data is not stored in a human-readable format.  It...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: running sum cursor

    Sean Lange wrote:

    RocksteadyDev wrote:

    T-SQL 2012 has a new built in function to give a running total, so you don't need a cursor for running totals that sum distinct counts. Previously sum...

    • This reply was modified 6 years, 8 months ago by drew.allen. Reason: edited to break up long line of code

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Rownumber()

    Did you really think it was necessary to post 5000 lines of data to illustrate your issue?

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Trying to create Nested SUM OVER Function for backwards running total.

    From your data, I think what you're really dealing with is a overlapping intervals problem.  You have overlapping intervals (student start and end dates) and you need a running count...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: running sum cursor

    This thread is SEVEN YEARS OLD, so it's not safe to make any assumptions about what the OP is currently using.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 406 through 420 (of 4,085 total)