Forum Replies Created

Viewing 15 posts - 31 through 45 (of 79 total)

  • RE: Convert comma to single quotes

    The above will not produce exact expected results for some of the cases:

    Yes, but in general your solution won't too. Imagine a few more spaces at the end or begining.

    declare...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: Convert comma to single quotes

    Try using replace function like this:

    declare @a varchar(100) = 'akraft,crunckel';

    set @a = ''''+replace(@a,',',''',''')+''''

    select @a


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: find max

    vinu512 (8/17/2012)


    From what I understand, this should do it:

    Declare @position Char(33)

    Set @position = 'sales'

    Select ename, job From

    (

    Select *, ROW_NUMBER() Over (Partition By job Order By Sal) As rn From Ex...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: New to SQL Server 2008

    Hi! Maybe, if you are familiar with 2005, it would be reasonable to start from here.

    What's New (SQL Server 2008)


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: Why doesn’t the last record win?

    We also may update like this:

    with cte as

    (

    select

    rn = row_number() over (partition by ClientKey order by GuarantorKey desc),

    *

    from

    #tmpGuarantor

    )

    update t

    set t.GuarantorKey = cte.GuarantorKey

    from

    #tmpTest t

    join cte on t.ClientKey =...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: comma separate value show as table

    dwain.c (8/16/2012)


    Here's another way that is a bit faster than using PARSENAME.

    If we speak for performance aspect, I think it is not parse name, rather it is replace impact, because...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: any ideas on how to spead up this query?

    It would be also nice to see actual plan in xml. And maybe some info about a table, e.g. size, structure and indexes.


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: Adding/subtracting columns to get total

    NULL+123 = NULL

    NULL + Anything = NULL.

    That's how it works. use isnull function over the fields, like that

    isnull(MyField1,0)+isnull(MyField2,0)+...

    than if the field will contain null - it will be replaced by...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: UPDATE when the values are the same

    This theme was covered in details here

    I encourage you to read it.Paul White: Page Free Space - The Impact of Non-Updating Updates


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: comma separate value show as table

    In particular simple case, when: 1) there not more than 4 columns, 2) column data fits nvarchar(128) (sysname), 3) no dots in data - you may use parsename function like...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: Update using more than one table

    If I understand you correctly, smth like this:

    update a

    set

    totalmarks = case when b.class2 > a.class1 then maths + english else totalmarks end

    from

    A a

    join B b on -- some join condition

    Upd:

    removed...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: much worse execution plan calling stored procedure vs. query window

    sqlnyc (8/10/2012)


    Gail - please forgive my terminology. I did indeed modify existing indexes with INCLUDE.

    Best wishes,

    SQLNYC

    Thank's for the plans! It is now much more clear!

    Well, I think, I figured...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: much worse execution plan calling stored procedure vs. query window

    Wait for a moment!

    Look at the plan.

    Here is what good plan says:

    @PayrollID value = (345)

    Here is what bad plan says:

    Compiled param value = (334329)

    Run param value = (345)

    Seems there is...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: much worse execution plan calling stored procedure vs. query window

    sqlnyc (8/10/2012)


    Thanks for the replies.

    My understanding about parameter sniffing is that the optimizer uses the plan that was compiled after first use, which may not be optimal for subsequent...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

  • RE: Applying query across Server.

    Maybe you mean, that you want to execute a cross server query?

    You may add linked server. After that you may query remote table specifying 4 part name:

    select * from MyServer.MyDatabase.MyScheme.MyTable.

    You...


    I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
    Blog: http://somewheresomehow.ru[/url]
    Twitter: @SomewereSomehow

Viewing 15 posts - 31 through 45 (of 79 total)