Forum Replies Created

Viewing 15 posts - 2,221 through 2,235 (of 2,462 total)

  • RE: Max of 2 dates

    Sean Pearce (6/26/2013)


    Alan.B (6/25/2013)


    Which is why I included two solutions: My original solution which I believe is correct and one which was cleaner and faster than the one Michael posted.

    Do...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    J Livingston SQL (6/25/2013)


    Alan.B (6/25/2013)


    Michael Valentine Jones (6/25/2013)


    select top 1

    a.[Date]

    from

    (

    select top 1 b.[Date] from table1 b order by b.[Date] desc

    union

    select top 1 c.[Date] from table2 c order by c.[Date] desc

    )...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    Michael Valentine Jones (6/25/2013)


    select top 1

    a.[Date]

    from

    (

    select top 1 b.[Date] from table1 b order by b.[Date] desc

    union

    select top 1 c.[Date] from table2 c order by c.[Date] desc

    ) a

    order by

    a.[Date] desc

    I think...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    Shadab Shah (6/25/2013)


    J Livingston SQL (6/25/2013)


    Shadab Shah (6/25/2013)


    I search for Date functions for finding the max of the 2 dates. But such function does not exits.

    Is there any easy way...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: how to restore a stored procedure from a backup

    If you have db backed up as a single .BAK file then restoring the database is the only way I can think of; there is no way to dig around...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: How to create the Dynamic Table...

    Are you looking for something like this...

    --(1) THE DATA

    IF OBJECT_ID('ajbtest.dbo.PivotA') IS NOT NULL

    DROP TABLE PivotA;

    CREATE TABLE dbo.PivotA (IDT int, A int, B int);

    INSERT dbo.PivotA VALUES (24,1,-1),(24,2,-2),(24,3,-3),(24,4,-4),(25,5,-5),(25,6,-6),(25,7,-8),(26,8,-8),(26,9,-9),(26,10,-10);

    --SELECT * FROM dbo.PivotA;

    --(2) THE...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Report keeps on failing

    sabah_seattle (6/14/2013)


    Hello sql1411,

    Thanks for responding. Here is the error I am getting -

    An error occurred during local report processing

    An error has occurred during report processing.

    Query execution failed for dataset "Sales".

    Login...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: What Queries/SPs Are Running Right Now ?

    HowardW (6/13/2013)


    You can write your own queries, using the DMVs, which is a good learning exercise, but I'd recommend using the brilliant sp_whoisactive.

    I wanted to second that.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: .sp_send_dbmail sending an XML File dashes in front of -<Label> ??

    To get rid of those dashes you could do something like this:

    DECLARE @x XML,

    @x1 varchar(1000)='

    - <CLUB>

    -...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Calculate Previous Business Day Exclude Saturday, Sunday and Holiday

    You would need to do something like this:

    -- (1) SAMPLE DATA SETUP

    IF OBJECT_ID('tempdb..#tblHoliday') IS NOT NULL

    DROP TABLE #tblHoliday;

    IF OBJECT_ID('tempdb..#dates') IS NOT NULL

    DROP TABLE #dates;

    --Holiday table, I only added New Years,...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Identify postcode from multiple fields

    Ed Wagner (6/12/2013)


    There are plenty of articles out there on getting started doing it .NET. Here's one: http://msdn.microsoft.com/en-us/magazine/cc163473.aspx.

    Depending on how you write it, this approach can be very efficient.

    After...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Identify postcode from multiple fields

    mike.dinnis (6/12/2013)


    Hello,

    I have a table with five fields used to hold address data. Due to poor practices the users have been able to enter any data in any field. They...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: slowly changing dimension?

    I have a solution that will work with your sample data. I was trying to come up with something that works when there are more than 3 records but this...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SQL commands to learn

    vxhughes (6/6/2013)


    Thanks to all for their recommendations.

    I've already started on

    http://beginner-sql-tutorial.com/sql-commands.htm

    and

    http://www.w3schools.com/sql/sql_intro.asp

    and I've bookmarked "Stairway to T-SQL DML" at

    http://www.sqlservercentral.com/stairway/75773

    A couple of quick questions:

    • Which of Itzik Ben-Gan's T-SQL fundamentals books do I...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SQL commands to learn

    OTF (6/6/2013)


    bgraham 64271 (6/5/2013)


    SQLSACT (6/5/2013)


    vxhughes (6/4/2013)


    Can anybody recommend a good online guide to SQL commands? Or at least a list of the ones I should learn first?

    Have a look...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 2,221 through 2,235 (of 2,462 total)