Forum Replies Created

Viewing 15 posts - 271 through 285 (of 7,626 total)

  • Reply To: Create a dynamic script to create view for all tables having MAX columns

    I generated SQL separately for each view, even though that requires a cursor.  In this specific case, I think you may want to be able to control things table by...

    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: Function Returning NULL on Specific Server Instance, 0 on Other Servers

    Somehow you left out the "SET @MyBit = 0" on one function?

    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: Create a dynamic script to create view for all tables having MAX columns

    Except stay completely away from INFORMATION_SCHEMA views, which are more overhead anyway.  Use sys.tables, sys.columns, etc., instead.

    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: Create a dynamic script to create view for all tables having MAX columns

    And what would you want to name the view?

    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: Conditionally Selecting Rows within Union

    Sample data and results are almost always clearer than just a textual explanation.  I hope this matches what you need:

    SELECT
    ISNULL(t2.CarColor, t1.CarColor) AS CarColor,
    ...

    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: Conditionally Selecting Rows within Union

    IF I understand the q correctly, then:

    SELECT
    ISNULL(t2.CarColor, t1.CarColor) AS CarColor,
    t1.CarName,
    t1.CarStatus
    FROM Db1.CarTbl1 t1
    LEFT OUTER JOIN Db2.CarTbl27...

    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: Replace and like - oh great

    SQL wouldn't necessarily have to scan the entire table, if the relevant columns happened to be in a nonclus index -- not likely here, but theoretically possible.

    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: Log File v.large, has not been backed up.

    Sorry, I couldn't tell you that, I'm not a SAN/hardware person, just a DBA.

    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: Log File v.large, has not been backed up.

    (1) Yes, to me, highly impractical.

    (2) No real need to make the db read only:

    (A) take diff backup (if you feel safer that way);

    (B) Switch to SIMPLE recovery;

    (C) Issue a...

    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: Data Archiving

    I would do this the other way around.  That is, rather then deleting 15 years' worth of data, copy the current 2 year's worth of data to another db.  Then,...

    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: Performance optimization by excluding JOIN with tables only with one record

    lapus014 wrote:

    But if we have LEFTor RIGHT JOIN as below,is it possible to improve something at this case?

    SELECT pr.column1, pr.column2 FROM PlayersTypesAS pr WITH(NOLOCK) INNER JOIN dbo.Players AS p WITH(NOLOCK)...

    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: Performance optimization by excluding JOIN with tables only with one record

    Perhaps, but I would really expect SQL to generate effectively the same query plan for either code for something this straight forward.

    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: Performance optimization by excluding JOIN with tables only with one record

    Your code is not really consistent, but here's my best guess:

    UPDATE pt 
    SET LastModifiedDateTime = @dt
    FROM dbo.PlayersTypes AS pt
    INNER JOIN @TableTypePlayersRestrictions AS prt ON prt.PlayersRestrictionID = pt.PlayersRestrictionID

    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: SQL DB 2 TB

    I'd try to use differential backups, assuming you have a large amount of free disk space in qa, or could get it easily.

    When you do a full backup in prod...

    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: t-sql substring to return right 6/7 characters after value in a Free Text field

     

    SELECT 
    [freetext],
    CASE WHEN FC_start = 0 THEN '' ELSE RTRIM(SUBSTRING([freetext], FC_start, FC_length)) END AS value
    FROM dbo.testdata
    CROSS APPLY (
    ...

    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 - 271 through 285 (of 7,626 total)