Forum Replies Created

Viewing 15 posts - 2,221 through 2,235 (of 4,085 total)

  • RE: Pass table variable to exec SQL Server

    You really should be using sp_execute_sql rather than EXEC (). sp_execute_sql will allow you to pass in parameters, which helps to protect against SQL injection.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Extract specific data

    larrycook74 (10/24/2016)


    it gave me all three "dRank"...

    There is no dRank in my query. I specifically removed it because it was unnecessary.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Extract specific data

    It does work, your partition is wrong.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Extract specific data

    larrycook74 (10/24/2016)


    Hi Drew,

    That didn't work... 🙁

    Here is some sample data, when you have time to check it out.

    Create Table tempSero

    (

    CaseId varchar(20)

    , rDate...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Get information about people who are free on a particular day

    This is known as the packing intervals problem. Itzik Ben-Gan wrote up a New Solution to the Packing Intervals Problem. You're going to need to pack the intervals...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Extract specific data

    Since we don't have sample data to work with, it's difficult to come up with a query. Try this approach.

    WITH CTE AS (

    SELECT

    r.CaseFileIdentifier

    , DateAdd(hour,-7,r.ReferredOn) as ReferralDate

    , sv.Name

    , sv.Value

    ,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Optimising SQL to find where times lie within days of the week

    I would just use integer division and remainders. x / ticks_per_day gives the number of full days that have passed and x % ticks_per_day gives the remaining ticks. ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Help with SELECT where clause (multiple values in multiple columns)

    If I understand correctly, just change your ORs to ANDs in your original query. You're getting rows where ANY column does not contain any of those values, but you...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Big data: transfer x-number of rows per batch?

    Since you've posted to a SQL 2012 forum, you might want to use a feature that was introduced in SQL 2012 specifically for paging: OFFSET/FETCH.

    DECLARE @pg INT = 1,

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: query for count

    Something like the following?

    WITH absences AS (

    SELECT *, COUNT(absence_dt) OVER( PARTITION BY student_id ORDER BY attendence_dt ROWS UNBOUNDED PRECEDING) AS absence_cnt

    FROM attendence

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Looking for way to dynamically replace street suffix with abbreviation based on tables

    jeff.born (10/21/2016)


    Drew,

    I'm not sure how to write the ISNULL version.. This syntactically incorrect version I came up with is:

    The ISNULL replaces the result of the STUFF with the original address.

    You...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to check Inserted records and Error for below procedure.

    When switching from row-based processing to set-based processing, you have to understand that the set will either succeed or fail as a whole. You can either pre-screen your data...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Looking for way to dynamically replace street suffix with abbreviation based on tables

    jeff.born (10/21/2016)


    This works great for the addresses that have a street suffix in them, however I have many addresses like this:

    INSERT INTO [dbo].[Address] ([Address]) VALUES ('48 Martin Luther King');

    There is...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: group by

    If value isn't correct and SUM(value) isn't correct, it's not clear what IS correct without sample data and expected results. Please read the first link in my signature to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Performance improvement on statement.

    Unfortunately, I'm not sure that it will work in this case, because the article does calculations on constants, but reworking it for this, would require doing those same calculations on...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,221 through 2,235 (of 4,085 total)