Forum Replies Created

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

  • 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, 2 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".

  • Reply To: Help with Database design Schema

    > So the format of the file reference for Branch A would be, A500/2024 and for branch B, B200/2024, etc. <<

    That sorta violates 1NF, right?  Personally I'd suggest not doing...

    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: Help with Database design Schema

    Some things are somewhat unclear.

    I don't see "district" at all in the ERD, although you reference it extensively in your discussion.

    "Entries" is a rather vague Entity.  And it looks 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: Decimal Datatype with negative value

    It should be more efficient to do that using a trigger rather than doing a separate UPDATE after the load.  The trigger would also allow for indirect notification (you wouldn't...

    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: need help in optimizing long running UPDATE statements

    I would think one UPDATE -- with the IN condition added -- would be much better than 3 separate UPDATEs, since the main table will then only have to be...

    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: Help with date range subquery

    Typically EXISTS / NOT EXISTS is most efficient when it's a viable option.

    You'll want to have a (nonclus) index on B ( AppId, NotificationDate ).  If the table already has...

    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: Help with date range subquery

    Agree with Phil, that's a critical q.

    Also, efficiency will depend on the indexes on the tables.  You'll need to be able to review indexes.

    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,613 total)