Forum Replies Created

Viewing 15 posts - 4,471 through 4,485 (of 7,619 total)

  • RE: How to figure out whether data is selected from dirty pages?

    GilaMonster (1/22/2016)


    SQL Guy 1 (1/22/2016)


    They agreed with second option, but with condition that the "dirty" records will be marked somehow in the report. So they conditionally accept it.

    Nice idea,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: referencing same column in same table but coulum has different values

    My best guess at the code, known as a "cross tab" query, is below. You're not using anything from table B in the code. Are these really the...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: How to figure out whether data is selected from dirty pages?

    Is the ETL process working in such a way that it gets a table lock? If so, you may be able to remove the table lock and accept that...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Date Function

    SumonB (1/20/2016)


    What if today's date is 5th January' 2016.

    Will it show the start date as 21st December'2015 and End date as 5th January'2016

    Yes ... and here's the proof:

    Declare @StartDate Datetime,

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Date Function

    If you always need exactly 15 days, just do this:

    Declare @StartDate Datetime,

    @EndDate Datetime

    set @EndDate=DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0) --strip time from date

    set @StartDate = DATEADD(DAY, -15,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    Orlando Colamatteo (1/20/2016)


    ScottPletcher (1/20/2016)


    Orlando Colamatteo (1/19/2016)


    ScottPletcher (1/19/2016)


    Of course that code doesn't specify the date key, so it will do a full table scan. Again, vastly too much overhead when two...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Date Function

    Sergiy (1/19/2016)


    SumonB (1/19/2016)


    Hi Scott,

    I executed the code today..

    Declare @StartDate Datetime,

    @EndDate Datetime

    if DAY(@StartDate) >= 7

    set @StartDate = DATEADD(day, -15, DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0))

    else

    set @StartDate = DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    Orlando Colamatteo (1/19/2016)


    ScottPletcher (1/19/2016)


    Of course that code doesn't specify the date key, so it will do a full table scan. Again, vastly too much overhead when two very simple arithmetic...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    Orlando Colamatteo (1/18/2016)

    CREATE FUNCTION dbo.get_day_in_nth_week_in_month

    (

    @Year SMALLINT,

    @MonthNumber TINYINT,

    @WeekInMonthNumber TINYINT,

    @DayName VARCHAR(9)

    )

    RETURNS TABLE

    AS

    RETURN

    (

    SELECT day_dt,

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    It's not nearly that complicated to get the nth given day of any month:

    DECLARE @SecondTuesdayOfMonth_InThreeMonths datetime2

    --set to last possible day = 14th of month, then ...

    SET @SecondTuesdayOfMonth_InThreeMonths = DATEADD(DAY, 13,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    SQL Agent schedules all of it jobs from msdb, and I don't see anything that looks like a calendar table in it.

    Keep in mind, too, you've also created a potential...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    Orlando Colamatteo (1/16/2016)


    ScottPletcher (1/16/2016)


    It's more efficient to avoid I/O when you can.

    There could be a trade off for CPU and coding effort. If you wrapped the calculation into an iTVF...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    Orlando Colamatteo (1/16/2016)


    ScottPletcher (1/16/2016)


    Simple mathematical calcs could give you any of those dates, with no need for I/O against a table. But I'm also not attempting actual code without...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: SSMS no indicator for Index Disabled?

    It simply probably didn't occur to the SSMS developers at the time to visually mark it. They probably didn't deal with disabled indexes at the time and almost certainly...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Need to calculate nth day of nth month

    Simple mathematical calcs could give you any of those dates, with no need for I/O against a table. But I'm also not attempting actual code without existing data definitions/DDL.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 15 posts - 4,471 through 4,485 (of 7,619 total)