Forum Replies Created

Viewing 15 posts - 4,321 through 4,335 (of 7,619 total)

  • RE: Help me in executing this CASE Statement

    IF EXISTS(SELECT 1 FROM dbo.ShiftScheduler WHERE ShiftType=2 AND Emp_Code='2414')

    SELECT FromDate,enddate,Shift,ShiftType

    FROM dbo.ShiftScheduler

    WHERE ShiftType = 2 AND EndDate...

    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: Recursive Table - Query Help

    Try code something like below.

    Btw, the GroupAssignment table does not need an identity column. The unique clustering key should be either ( GroupID, UserID ) or (...

    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: Determine ANSI_PADDING status in TSQL

    Fwiw, I prefer the a different way to check the current ansi / connection settings, using:

    @@OPTIONS

    I actually use a table of config values so the code is more readable, but...

    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: IF, THEN in T-SQL?

    You can use CROSS APPLY to assign an alias name to value(s). You can then use that alias in subsequent code, even in another CA. That is, alias...

    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: why we should delete old data and what could be the chunk size for delete 2.5 million records

    If the table is clustered first on that datetime, the purge is easy and it should have very minimal effect on current queries.

    If it's clustered differently, you have a more...

    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: sql swap dated fields

    You probably want to verify that the dates are actually backwards before swapping them:

    update tableA

    set StartDate = EndDate,

    ...

    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: Please help me improve the performance of this query

    Can you give any example of where converting a literal value to appropriate non-unicode literal could ever cause SQL a performance issue?

    Or for dates. Our rule is you convert...

    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: EXECUTE AS question

    chuck.forbes (4/18/2016)


    Are you saying that I should put this restore-capable user account into the db_owner role for the database? I haven't heard of making someone a dbo user (I always...

    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: Please help me improve the performance of this query

    TheSQLGuru (4/18/2016)


    It's absolutely not coding "laziness". It's simply to allow for data type changes later without causing performance issues in the code.

    Completely disagree with the first sentence. And even more...

    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: Please help me improve the performance of this query

    TheSQLGuru (4/18/2016)


    ScottPletcher (4/18/2016)


    TheSQLGuru (4/16/2016)

    New rule: YOU WILL, ALWAYS WITHOUT EXCEPTION, USE EXACTLY THE SAME DATA TYPE AS THE COLUMN TO THE BEST OF YOUR LANGUAGES ABILITY TO DO SO!

    THAT 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: EXECUTE AS question

    Yeah, definitely not 'sa' or some other existing/standard user.

    Create a new user, native SQL user will do if that's available to you, and grant it just the specific permissions it...

    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: Please help me improve the performance of this query

    TheSQLGuru (4/16/2016)

    New rule: YOU WILL, ALWAYS WITHOUT EXCEPTION, USE EXACTLY THE SAME DATA TYPE AS THE COLUMN TO THE BEST OF YOUR LANGUAGES ABILITY TO DO SO!

    THAT IS A HUGE...

    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: ISNULL VS COALESCE on nullible and not null columns Sargability comparison

    TheSQLGuru (4/15/2016)


    ScottPletcher (4/15/2016)


    TheSQLGuru (4/15/2016)


    ScottPletcher (4/15/2016)


    The simplest rules is:

    Never use ISNULL in a WHERE or JOIN clause.

    Whether the column is nullable or not is irrelevant.

    The proper way to code this:

    where isnull(SalesOrderID,-1)...

    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: Data corruption aftermath -- future prevention

    dan-572483 (4/15/2016)


    Excuse me? Are you saying that if a database is mirrored and disk-level corruption occurs the SQL will just pull the data from the mirror??

    And I believe it...

    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: ISNULL VS COALESCE on nullible and not null columns Sargability comparison

    TheSQLGuru (4/15/2016)


    ScottPletcher (4/15/2016)


    The simplest rules is:

    Never use ISNULL in a WHERE or JOIN clause.

    Whether the column is nullable or not is irrelevant.

    The proper way to code this:

    where isnull(SalesOrderID,-1) = 43665...

    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 - 4,321 through 4,335 (of 7,619 total)