Forum Replies Created

Viewing 15 posts - 2,236 through 2,250 (of 4,085 total)

  • RE: Performance improvement on statement.

    The problem with ranges is that it requires two range predicates (>=, >, <=, or <), but SQL indexes only efficiently handle one range predicate. There is a way...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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

    Here is an article on Handling Errors in SQL Server 2012[/url]. It's not clear whether the errors you mention are being produced earlier in the procedure or as part...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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

    I tweaked the code (added some REVERSEs).

    SELECT Address_pk, [Address],

    STUFF(a.[Address], ss.search_idx, LEN(ss.search_val), ss.PostalServiceStandardSuffixAbbreviation) AS AddressAbbreviated

    FROM [Address] a

    OUTER APPLY (

    SELECT TOP 1 *, LEN(a.[Address]) - LEN(txt.search_val) - NULLIF(CHARINDEX(REVERSE(txt.search_val), REVERSE(a.[Address])), 0)...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

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

    This works with the sample data and doesn't produce the second record for Court Place.

    SELECT Address_pk, [Address],

    STUFF(a.[Address], ss.search_idx, LEN(ss.search_val), ss.PostalServiceStandardSuffixAbbreviation)

    FROM [Address] a

    OUTER APPLY (

    SELECT TOP 1 *, CHARINDEX(txt.search_val, a.[Address])...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Get Rows On Given Range

    In some circumstances, the following may perform better than the ROW_NUMBER version.

    SELECT t2.*

    FROM #table1 t

    CROSS APPLY (

    SELECT TOP ( t.qty ) *

    FROM #table2 t2

    WHERE t2.forename = t.name

    ORDER BY t2.cost DESC

    )...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Pivoting data

    Aquilagb (10/19/2016)


    Thank you for the reply...

    The query is this:

    SELECT TOP 1000 [LTStringId]

    ,[LanguageCode]

    ,[LTStringType]

    ,[ElementName]

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: ReportServer Query for Last RunBy Other than, unless...

    If you do decide to convert the dates to VARCHAR rather than BINARY, you need to convert it in a format that will sort correctly, such as YYYY-MM-DD hh:mm:ss.

    From several...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: ReportServer Query for Last RunBy Other than, unless...

    Budd (10/19/2016)


    Thanks very much Drew.

    In regards to my collation usage, and the COALESCE in the WHERE clause you are so right !! This was written Months ago and I didn't...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: ReportServer Query for Last RunBy Other than, unless...

    I think this will work without any CTEs. We use Crystal Reports, so I didn't have a ReportServer database available to check things like the collation and data types...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Copy a record via trigger

    You should be using the INSERTED virtual table instead of pulling the data from the original table. Every time the trigger is run, you're copying all mails that were...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Summarizing COUNTs - Flumoxed by getting my SQL right...

    The purpose of the windowed functions is to easily combine detail data with summary data, but you only want the summary data. Just use a simple GROUP BY instead...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SVN Source Control of Database Objects - What Prevents a Bad Overwrite in this Case?

    Jeff Moden (10/18/2016)


    1. Is SVN smart enough to tell folks that there's a conflict when folks try to check in the proc at point (B) because there's a branch in...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: sp_MSforeachdb newbie trying to get query to run across 100+ databases.

    Phil Parkin (10/17/2016)


    This command runs in its own context. What that means is that you have to put all of the SQL - including the variable declarations - into your...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Upgraded to 2014 from 2012, what happened to my colors?

    In SSMS go to Tools > Options > Environment > Fonts and Colors > Plain Text and set your desired Item Foreground.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: lookup value for each row

    marc.corbeel (10/17/2016)


    On the sample data their were no indexes indeed, but on the db I tested the solutions, there are indexes on the currency id and on the date...

    This sounds...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,236 through 2,250 (of 4,085 total)