Forum Replies Created

Viewing 15 posts - 6,316 through 6,330 (of 7,613 total)

  • RE: Difference between two dates ignoring the year

    Luis Cazares (11/26/2013)


    Here are 2 options to perform your calculation:

    SELECT ABS(DATEPART( dayofyear, CutoffDate) - DATEPART( dayofyear, GETDATE())),

    ABS(DATEDIFF( day, DATEADD( year, DATEDIFF( year, CutOffDate, GETDATE()), CutOffDate), GETDATE()))

    FROM #Temp

    I don't think 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: Backup Time vs Restore Time

    I'd expect the restore time to generally be longer; if restoring to a new database, potentially significantly longer.

    For a backup, SQL only needs to backup the active portion of 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: Maintaining the Value of My Primary Key Question

    You could create a separate "key master" table, containing only an identity column and the four natural key columns, clustered on the natural key columns, NOT the identity.

    Then, the first...

    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: Collect tables have most row changed during specfic period

    Use view "sys.dm_db_index_operational_stats".

    Capture the values at the start time, then recapture them at any subsequent time, subtract the two values, and voila, you have the mods that occurred during 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: Comparing Table Valued Parameters

    I'm not sure why you would want to insert all iterations of the list of values into the countryid table, but this should fix a couple of the potential errors...

    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: DETECT ROWS CHANGED IN A TABLE to transfer in a datawarehouse

    registrazioni 75612 (11/22/2013)


    Ty.

    Please, what is IIRC please?

    just a link to a doc site.

    Ty

    Max

    IIRC == "If I recall correctly" == hedge in case I'm wrong 🙂

    For more info on Change Tracking...

    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: DETECT ROWS CHANGED IN A TABLE to transfer in a datawarehouse

    CDC could do it too, of course, but it has more overhead and is available only in Enterprise Edition; it's overkill for what you've described you need.

    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: DETECT ROWS CHANGED IN A TABLE to transfer in a datawarehouse

    Change Tracking should handle your situation easily and completely. IIRC, CT requires that the table have a PRIMARY KEY defined.

    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: Update column based on other column value

    Of course not all CTEs are going to be updateable, it will depend on the specific coding of the CTE ;-).

    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: Best Way to Create Multiple Columns from A Single Column

    You don't have to use two ROW_NUMBER() clauses/entries:

    ;WITH detail AS (

    SELECT *, ROW_NUMBER() OVER (ORDER BY id) AS row_num

    FROM #test

    )

    SELECT

    ...

    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: Pivot All Columns

    Luis Cazares (11/20/2013)


    As all values will show in a single column, the first value will determine the column data type.

    I don't think that's right. I think SQL uses data...

    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 display totals grand total in t-sql

    first a 800

    first a 200

    first a 1000

    TOTAL 2000

    first b 100

    first b 200

    TOTAL 300

    second a 400

    TOTAL 700

    second b 400

    TOTAL 1100

    GRANDTOTAL 5100

    I don't understand the totaling logic you want.

    "TOTAL 700"?? Is...

    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: Is point-in-time possible after restore

    I think so, but I couldn't swear to it. I think the differential bitmaps are restored as-is with the db, and not reset, but I'm not 100% sure. ...

    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: Is point-in-time possible after restore

    Donald Sawford (11/18/2013)

    I know that a full backup should be run immediately after a restoration

    That shouldn't really be necessary, assuming you still have the backups you used to do 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: Most efficient way to get a single unique combined record for distributed information corresponding to same ID

    MAX(age) seems safe enough -- no one gets any younger :-).

    Combining MIN(name) and MAX(name) would allow one name change ... that should handle everyone, right!?

    /*

    insert into #temp(id,name)

    select 2,'Jane Single'

    insert into...

    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 - 6,316 through 6,330 (of 7,613 total)