Forum Replies Created

Viewing 15 posts - 211 through 225 (of 7,619 total)

  • Reply To: Data Archival: 1 table (Database A) to 1 table (Database B)

    Cluster both tables by ( StartDateTime, ID ) rather than just ID.  Then, since you'll be moving data in cluster key order, you can just use a standard copy-then-delete approach.

    Btw,...

    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".

  • Reply To: Slow update on temp table

    Another possibility is, assuming that:

    (1) column avol was NULL before this UPDATE

    (2) your server still has the default FILLFACTOR 0f 0 (=100)

    Then this UPDATE could a lot of leaf page...

    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".

  • Reply To: Should I create tables with dynamic SQL?

    You *might* also want some background process to remove carts after a certain period of time, or maybe not.  For example, I can go into Amazon, put something in my...

    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".

  • Reply To: Should I create tables with dynamic SQL?

    Creating and dropping tables is significant overhead.  You'd be much better of, as others have noted, with a permanent table.  You could key rows in that table by user id...

    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".

  • Reply To: Query run from SQL agent, not returning same results as from query window

    Just use a method that works under any/all DATEFIRST settings, much simpler and safer:

    /* calc immediately previous Sunday; day 0 = Monday, so day 6 = Sunday...

    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".

  • Reply To: Join to a value that might be in multiple columns

    With 20 name columns, how do you verify that all the names are unique across all rows?  And, if they're not unique, how do you know which id to assign...

    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".

  • Reply To: gut check dba's recommendation to increase log to 200gig

    The CHECKPOINT is one of the steps required before SQL can mark the existing log space as reusable.  Since you're in SIMPLE recovery model, the only thing that could prevent...

    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".

  • Reply To: gut check dba's recommendation to increase log to 200gig

    Also, you should issue an explicit CHECKPOINT on the db when you want logs to clear.  Part of the requirement for freeing log space, SIMPLE recovery, is that a CHECKPOINT...

    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".

  • Reply To: Dynamically get max of a field from table

    Jonathan AC Roberts wrote:

    GrassHopper wrote:

    Scott, How do I add the tablename to this query?  So it displays the tablename with the result of the max().

    SET @sql_template = N'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".

  • Reply To: Dynamically get max of a field from table

    I would make it truly more generic (might as well).  Definitely avoid the use of INFORMATION_SCHEMA views, since they are not 100% reliable and often seem very slow.  I, too,...

    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".

  • Reply To: Query help please

    SELECT ca.*
    FROM dbo.history h2
    CROSS APPLY (
        SELECT h1.*
        FROM dbo.history h1
        WHERE h1.hist_id = h2.hist_id - 1
        UNION ALL
        SELECT h2.*
    ) AS...

    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".

  • Reply To: Outer join table where there is 2 foreign keys to join

    You're welcome!  I had to make one correction to the query above, btw.

    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".

  • Reply To: Outer join table where there is 2 foreign keys to join

    Something like this:

    FROM
    ...
    dbo.Locations L ON AL.LocationID = L.LocationID OUTER APPLY (
    SELECT TOP (1) D.*
    FROM dbo.Applicant_Disposition D
    ...

    • This reply was modified 2 years, 4 months ago by ScottPletcher. Reason: Added "TOP (1)" to outer apply query that I forgot to put in earlier, D'OH

    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".

  • Reply To: How to find orphaned user and aliased SQL Login with t-sql

    View sys.database_principals will have the sid of the login (but not the login name itself).  View sys.server_principals also has a sid.

    If the login has been dropped, the sid may still...

    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".

  • Reply To: Creating New Version of a Database

    Naturally you can't use the current file names, since they're already in use for the original db.  Use "WITH MOVE" to "tell" SQL the new file names

    RESTORE DATABASE ACME_DEV FROM DISK...

    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 - 211 through 225 (of 7,619 total)