Forum Replies Created

Viewing 15 posts - 8,386 through 8,400 (of 8,731 total)

  • RE: help with a query

    For a small improvement, change the "Original" definition:

    Original AS(

    SELECT CASE WHEN C1 < C2 THEN C1 ELSE c2 END AS C1,

    CASE WHEN C1 < C2 THEN C2 ELSE C1 END...

    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: End Of Year

    Eugene Elutin (9/20/2012)


    jcrawf02 (9/20/2012)


    Eugene Elutin (9/19/2012)


    Jeff Moden (9/18/2012)


    Eugene Elutin (9/18/2012)


    Please ignore this stupid remark!

    Easy, big guy. You're right but that's something that he would say. 😉

    I've spent 5...

    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: help with a query

    I might be doing some extra work with this query and someone could find a better way to do it.

    However, it's an option that you can analyze.

    DECLARE @test-2TABLE(

    C1 int, C2...

    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: use column in Group By, but Hide column from the results set

    siggemannen (9/20/2012)


    These kind of queries have real usage, for example if you want to preserve "duplicate rows" of Col1, Col2, which cannot be preserved if you only Group By Col1

    Why...

    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: Creating Trigger To Update Total On 'Parent' Table

    I'm Firebird user, in Firebird context value (inserted, updated, or deleted) in trigger is always single row which not always true in Sql Server.

    To make it clearer for 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: help with a query

    It's not clear (at least for me). What logic do you use to say a field is a related field?.

    You should take a look at the link in my signature...

    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: use column in Group By, but Hide column from the results set

    You get too complicated. This should work.

    This will also give incomplete information on how the groups are made.

    SELECT Col1, Count(*) AS Count_Rec

    ...

    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: Sum with Multi Category and Group By Acc No ?

    For a dynamic solution, you should read this article:

    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs

    [/url]

    And maybe the first part as well.

    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: Check SQL Version

    I believe this would be safe and simple to validate it's 2008 or higher. Is it possible to use SQL Server 1? 😛

    IF CONVERT(int, CONVERT(char(1), SERVERPROPERTY('productversion'))) = 1

    BEGIN

    RAISERROR('Youc an only...

    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: End Of Year

    Instead of using UDFs (dbo.get_BOY) that will reduce performance, try looking at this article.

    http://www.sqlservercentral.com/blogs/lynnpettis/2009/03/25/some-common-date-routines/

    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: Northwind Database for SQL Server 2005

    Have you tried to google them?

    The first result when I searched Northwind was https://www.microsoft.com/en-us/download/details.aspx?id=23654

    It might be different for you since I'm using DuckDuckGo

    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: IF statement / Variables.. problems!

    I guess you can do this or several nested CASEs as you had on Excel.

    CASE WHEN Type1 <> 'RFS' THEN Detail1

    WHEN Type2 <> 'RFS' THEN...

    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 Help Needed

    CELKO (9/17/2012)


    2 points here. First, What does an IDENTITY value do other than uniquely identify an entity?

    Think of a parking garage (disk) and parking slot numbers (identity,...

    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 get current year

    Two options:

    SELECT TotalDueForTheCurrentYear = SUM(CASE WHEN YEAR(OrderDate) = YEAR(GETDATE()) THEN TotalDue ELSE 0 END),

    OverAllTotalDue = SUM(TotalDue)

    FROM #TestBasedOnYear

    SELECT TotalDueForTheCurrentYear = SUM(CASE WHEN OrderDate >= DATEADD( yyyy, DATEDIFF(yyyy,0,GETDATE()),...

    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: select query

    I came out with the same code as Jeff showed in the article, but I believe that Scott's code would be better as it is a single table scan instead...

    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 - 8,386 through 8,400 (of 8,731 total)