Forum Replies Created

Viewing 15 posts - 3,301 through 3,315 (of 7,613 total)

  • RE: Is null performance issues

    We could give a more specific answer if you'd show the actual code.
    But, for example, if it's something like this:

    WHERE ISNULL(date_column, '19000101') >= '20170101'
    then you don'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".

  • RE: Getting two different fields from two different tables


    INSERT INTO dbo.Tbl3 ( ID1, ID2 )
    SELECT (SELECT ID1 FROM dbo.Tbl1 WHERE Name1 = @Name1),
        (SELECT ID2 FROM dbo.Tbl2 WHERE Name2 = @Name2)

    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 count col1 and col2 as One, where col1 is not duplicate and col2 = fail


    SELECT Total_Input, Total_OK, Total_Fail,
         CASE WHEN Total_Fail > 0 AND Total_Fail > Total_OK THEN Total_OK
         WHEN Total_Fail > 0 THEN Total_Fail
       ...

    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: Index scan operator


    SELECT b.time * 1.0 credit, 0.0 credits, b.Id, b.date
    FROM staff b
    INNER JOIN (
        SELECT *, isnull(dbo.ConvDate2(e.Startdate),'20111101') AS Startdate_converted
        FROM emp

    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 update a value in WHERE clause for a bunch of SQL views

    aftab97 - Wednesday, June 27, 2018 3:36 PM

    ScottPletcher - Wednesday, June 27, 2018 3:31 PM

    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 update a value in WHERE clause for a bunch of SQL views

    I would hope that SQL itself would change it to an INNER JOIN when applicable, but it certainly won't hurt to try -- or verify using the query plan 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: How to update a value in WHERE clause for a bunch of SQL views

    aftab97 - Wednesday, June 27, 2018 1:39 PM

    That's an idea, but the tables are vendor proprietary tables and can't be modified.

    Does 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: Cross Database Permissions: SQL 2005 vs SQL 2016

    Check to see if the db A on each instance allows cross-database ownership chaining:

    SELECT is_db_chaining_on, *
    FROM sys.databases
    WHERE name IN ('A')

    If it's 1, then security...

    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: Index scan operator

    We would have to see the tables definition and the query itself to give you a reliable answer here.

    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: Compression

    squareoff - Tuesday, June 26, 2018 11:41 AM

    Thank you both.

    While researching, I read online that unless you are using WITH(TABLOCK) when inserting...

    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: Compression

    Yes, eventually it will get compressed automatically.  Although SQL doesn't actually do any page compression until the page gets full.

    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 determine if there are two midnights between two dates

    Just plain DATEDIFF(DAY, ...) will do that.  By definition, DATEDIFF counts the number of times the midnight boundary is reached/crossed between two dates/datetimes.

    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: Find differences without cursor


    DECLARE @CurrentYearStart INT
    DECLARE @CurrentYearEnd INT
    SET @CurrentYearStart = 201801
    SET @CurrentYearEnd = 201805

    SELECT *
    FROM @test-2 t_curr
    INNER JOIN @test-2 t_prev
    ...

    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: Violation of Primary Key Contraint

    To fix the immediate problem, try running:

    DBCC CHECKIDENT ('dbo.CmEvent', RESEED, 55845910)

    Better yet, rid yourself of the foolish and damaging myth that all tables should be clustered...

    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: Top 2 records with range

    ranitb - Wednesday, June 20, 2018 5:21 AM

    Does this help ?

    select top 2 *
    from (
        select max(u.iduser) iduser, max(u.score)...

    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 - 3,301 through 3,315 (of 7,613 total)