Forum Replies Created

Viewing 15 posts - 76 through 90 (of 2,893 total)

  • RE: Slow query performance extracting large tables from off-site linked server

    Try to use JOIN instead of IN:

    SELECT *

    FROM

    OPENQUERY([linkedservername],

    '

    SELECT ic.*

    FROM Encounter AS e

    JOIN Encounter_ItemChild ...

  • RE: concatenate with leading zeros

    Anyone wish to check how 2012 version would do?

    select FORMAT(C1*1000+c2,'000000000')

    from #TestTable

    😉

  • RE: Need help in query

    What defines period to be "Previous"

    We can see that the logic applied quite simple: "2014_S27" is previous to "2014_S28". But, is this always the format?

    If yes (two last digits...

  • RE: SubstringIndex

    If the above assumptions are right, then you can do this:

    ;with sd(v)

    as (select '10.0.1600.22'

    union select '233.38550.10.23423.2'

    union select '2353.345.4543'

    union select '456433')

    SELECT v, LEFT(v, ISNULL(NULLIF(p,-1),LEN(v)))

    FROM sd

    CROSS APPLY (SELECT CHARINDEX('.',v,CHARINDEX('.',v,CHARINDEX('.',v)+1)+1) -...

  • RE: SubstringIndex

    All values have the same format as in your sample?

    Always "dot" is a character you are after?

  • RE: How to perform mathematical formula without using case.

    GilaMonster (9/18/2014)


    shahi.alokchandra (9/17/2014)


    Actually i am having more then 100000 rows in table and if i use functions then my index might not be called.,that why want to avoid cases and...

  • RE: Merging Non overlapping timedates

    Jeff Moden (9/17/2014)


    Perhaps I'm missing something but for each job, wouldn't you just compare the start date of the job with the end date of the other jobs and the...

  • RE: Merging Non overlapping timedates

    Strange definition of overlapping eg. not counting cases when second job starts exactly at the same time as first does finish...

    Anyway, you may try this:

    ;WITH AnyOverlapping

    AS

    (SELECT ...

  • RE: How to perform mathematical formula without using case.

    Agree with Gail, but there is a shorted, more "cryptographic" version:

    declare @t table (Qty decimal(12,3),CF1 Decimal(12,3),CF2 Decimal(12,3),Flag TinyInt)

    insert @t select 10,2,6,0

    insert @t select 10,2,6,1

    select *, Qty * ((CF2/CF1) * ~cast(Flag...

  • RE: SQL Server says there's a self join in my view. In my opinion there's none...

    ...

    When i try to create the index SQL Server tells me that the index couldn't be created because of a self join on table person.

    ...

    A self join in my perception...

  • RE: Change Column order in dynamic pivot

    Most likely it is possible.

    To tell for sure we need a bit more details.

    Please refer to the link in my signature...

  • RE: Is Flag in SQL sever

    moz987 (9/12/2014)


    Hey,

    i guess the field "IsEllgible" is supposed to conaint values for true and false. Therefore i would recommend a bit field.

    Syntax should be

    ADD COLUMN IsElligible bit null

    The above also...

  • RE: Check the Variable is Empty or Null

    ...

    What is the easiest way of confirming whether a query was SARGable? Do you have to look at something in the execution plan?

    ...

    Create a temp table with single column (varchar,...

  • RE: Check the Variable is Empty or Null

    ...

    You are still not getting it are you? I'm trying to point out a discrepancy in the way SQL Server handles NULL, a simple example would be

    ...

    As a SQL Server...

  • RE: Check the Variable is Empty or Null

    Eirikur Eiriksson (9/11/2014)


    F. van Ruyven (9/11/2014)


    Eirikur Eiriksson (9/9/2014)


    Alan.B (9/9/2014)


    IF @user > '' --This checks for not null and not empty

    Cool. I never knew you could do that, very interesting :laugh:

    Edit:...

Viewing 15 posts - 76 through 90 (of 2,893 total)