Forum Replies Created

Viewing 15 posts - 901 through 915 (of 2,894 total)

  • RE: Need help with a script to identify count of negative and positive numbers in a record

    karthik M (11/19/2012)


    I tried for 6 numbers with the below query.

    select col1, col2, col3, col4, col5, Col6

    ,(s1+abs(s1)+s2+abs(s2)+s3+abs(s3)+s4+abs(s4)+s5+abs(s5)+ s6+abs(s6))/2 as Positive

    ...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Need help with a script to identify count of negative and positive numbers in a record

    dwain.c (11/19/2012)


    Eugene Elutin (11/19/2012)


    Michael Valentine Jones (11/19/2012)


    This should work also:

    select

    ...

    union select 7,19,15,12,-13

    union select 7,19,15,12,-13

    It's not so simple as appears at first glance, so check my version...;-)

    I think you meant to...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Avoiding cursor: Help with getting only first match after previous match

    CELKO (11/19/2012)


    ...

    Oh, IDENTITY cannot be a valid key for table either.

    ...

    Sorry to disappointing you again, but it really can!

    Have you tried it? If you need our...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Avoiding IF/ELSE

    CELKO (11/19/2012)


    ... Companies are identified by a DUNS (we even get radio ads for DUNS here in Austin!);

    ...

    That is real delight! How cool it is! There is only one...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Stored Proc - Nullable Parameters for optional filtering - handling LinkTable LEFT JOINs

    kramaswamy (11/19/2012)


    Hm - I'm actually kinda surprised that works. I would have thought it would fail because the WHERE condition would evaluate AS

    @TableB_ID IS NULL (TRUE) OR TableB_ID (Value OR...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Stored Proc - Nullable Parameters for optional filtering - handling LinkTable LEFT JOINs

    kramaswamy (11/19/2012)


    Yeah - I've used the Dynamic SQL approach before, and it does work pretty well, but I'm not a huge fan of it. Never knew about the RECOMPILE option...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Need help with a script to identify count of negative and positive numbers in a record

    Actually, I found even more elegant way:

    SELECT *

    FROM tablename

    ...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Need help with a script to identify count of negative and positive numbers in a record

    Michael Valentine Jones (11/19/2012)


    This should work also:

    select

    abs(sign(col1)+sign(col2)+sign(col3)+

    sign(col4)+sign(col5)) as NegativeCount

    sign(col1)+sign(col2)+sign(col3)+

    sign(col4)+sign(col5)+5 as PositiveCount

    from

    MyTable

    Have you tested it? You should try:

    CREATE TABLE [dbo].[MyTable](

    [col1] [int] NOT NULL,

    [col2] [int] NOT NULL,

    [col3] [int] NOT...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Stored Proc - Nullable Parameters for optional filtering - handling LinkTable LEFT JOINs

    Before using one or another technique, you should read this article from one of the best experts in this area:

    http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Need help with a script to identify count of negative and positive numbers in a record

    There is another, more mathematical way:

    If no zero values in your columns:

    select *, 5-Positives as Negatives

    from (select *,(sign(col1)+sign(col2)+sign(col3)+sign(col4)+sign(col5)+5)/2 Positives

    from tablename) sn

    And, if there are zero values:

    select...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Using Full-Text Search

    eranzo111 (11/19/2012)


    A dead end I guess... 🙁

    I was so happy when I saw the significant performence improvement when I used the full text search instead of the LIKE query,...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: how to remove characters char(0) to char(31)

    Jeff Moden (11/19/2012)


    ...

    To answer the rest, the only way to know for sure is to run a test or two. If someone would create a CLR to drop characters...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Using Full-Text Search

    SpringTownDBA (11/19/2012)


    Full text querying only does prefix matching, not postfix

    'erin*' matches 'erinblah'

    '*erin' doesn't match 'blaherin'

    There is no way to match the last half of a word.

    Ough, YES! And there is...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Joins-Left/Right Outer join

    John Mitchell-245523 (11/19/2012)


    If the WHERE clause includes a condition on the outer table, as your example does, then yes, the outer join is turned into an inner join. Try...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • RE: Joins-Left/Right Outer join

    farooq.hbs (11/19/2012)


    Hi guys,

    If we include 'where' clause to the Left/Right outer joins, does it becomes inner join by default??

    No it does not. It does really depend on what you put...

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 15 posts - 901 through 915 (of 2,894 total)