Forum Replies Created

Viewing 15 posts - 6,601 through 6,615 (of 8,731 total)

  • RE: Convert "TinyInt" into Binary format and store the multiple bit values in columns

    You can't use IIF unless you use 2012. For 2008 and previous versions, you need to use a (nested) CASE.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: How do you do a GROUP BY on a value that's changed by a CASE?

    You have 2 options:

    First one:

    WITH CTE AS(

    select case atr.Race

    when 32 then 'White'

    when 1 then 'Black/African American'

    when 2 then 'Asian'

    when 4 then 'American Indian/Alaskan Native'

    when 16 then 'American Indian/Alaskan Native'

    when 8...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: T-SQL options

    Eirikur Eiriksson (4/3/2014)


    Straight forward using Window functions

    Isn't that over complicating something that could be achieved like this?

    SELECT PONum

    ,POLineNum

    ,POSublineNum

    ,MIN(SublineInstance)...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Excel IIF to SQL

    You don't need several CASE, one is enough.

    Case when Status = 'Yes' then 'WithinStatus'

    when Hours< Benchmark Then 'OutsideStatus'

    Else 'WithinStatus'

    End as StatusType.

    If a...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: remove digits

    I always forget to use the nested replace solutions. It should outperform the splitter.

    I wish that SQL Server could include a "pattern replace" to get something like

    SELECT LTRIM( PATREPLACE(...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: T-SQL options

    Try using MIN() and group by PONum, POLineNum & POSublineNum.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: simple looping question

    The problem with your loop (other than being a loop:-P) is that you didn't initialize the @output variable. You're adding values to NULL and that's giving you NULL. If you...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Convert "TinyInt" into Binary format and store the multiple bit values in columns

    And if you need them as bit values:

    WITH SampleData AS(

    SELECT 55 Value UNION ALL

    SELECT 63 UNION ALL

    SELECT 26

    )

    SELECT Value,

    CAST(Value & 64 AS bit) AS Sat,

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Dynamic Pivoting in sql

    You might want to check this article:

    http://www.sqlservercentral.com/articles/Crosstab/65048/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: remove digits

    Simplifying Rodders code if digits will only appear at the beginning of the string.

    CREATE TABLE #Names(

    [Name] [varchar](200) NULL

    )

    INSERT INTO #NAMES

    VALUES ('22rajuvar'),

    ('45 vamsgui'),

    ('87 praveen'),

    ('67kumar'),

    ('32 vamshi'),

    ('123aaa'),('abcd'),('abc123'),('ab56def'),('xyz'),('9999'),('3946'),('9236'),('854')

    SELECT STUFF(NAME, 1, PATINDEX('%[a-zA-Z]%', NAME) -...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Convert "TinyInt" into Binary format and store the multiple bit values in columns

    Do you need something like this?

    WITH SampleData AS(

    SELECT 55 Value UNION ALL

    SELECT 63 UNION ALL

    SELECT 26

    )

    SELECT Value,

    (Value & 64) / 64AS Sat,

    (Value & 32) / 32AS Fri,

    (Value &...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Fill in the gap between 2 number range

    If you post your cursor solution, we could help you to convert it to a set based solution. It will run a lot faster if done properly and will change...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Fill in the gap between 2 number range

    I got lost with your last post. Do you mean that you really need to show all the possible values in the gap so they're available in a chart?

    If you...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to do duration in hours with ragged data

    To avoid those search problems once you've found something interesting, I would suggest to use the bookmarks on your browser (Chrome will synchronize them within all your devices) or the...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Fill in the gap between 2 number range

    First of all, you should provide sample data in a consumable form if you want to get better and faster answers. I did it for you this time because you're...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 6,601 through 6,615 (of 8,731 total)