Forum Replies Created

Viewing 15 posts - 4,381 through 4,395 (of 7,613 total)

  • RE: subtracting a case statement result from a Convert(char(8) result

    Maybe?:

    SELECT CONVERT(varchar(8), DATEADD(SECOND, DATEDIFF(SECOND, ISNULL(QueueDate, StartDate), EndDate), 0), 8)

    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: optimizing query

    If you decide to run it locally, clustering the tables to match the join logic will help:

    IF OBJECT_ID('tempdb.dbop.#RFI') IS NOT NULL

    DROP TABLE #RFI

    CREATE TABLE #RFI

    (

    COMMIT_NO CHAR(4),

    BODY_NO...

    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 improve performance of select statement in Dataware house app

    Does the clustering key start with Monthkey? And the partitioning key?

    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: Database Design Follies: NULL vs. NOT NULL

    kenambrose (3/10/2016)


    why do the same flawed arguments keep popping up?

    [[If you deal with a report and want all columns via left joins, then there will be nulls. ]]

    We don't know...

    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: Combine two working queries to get this month and last years this month numbers shipped

    For efficiency, the WHERE clause should include just the specific date ranges you need, rather than the entire year. Particularly if m1_KF.dbo.ShipmentLines is clustered first on smlCreatedDate (which 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: Issue with CASE on Random Number

    Try using a CROSS APPLY to assign an alias to the random number:

    SELECT

    RowSequence AS CaseID

    ,DateSequenceas [CaseDate]

    ,random_number

    ,CASE random_number

    WHEN1THEN'Black'

    WHEN2THEN'White'

    WHEN3THEN'Red'

    WHEN4THEN'Blue'

    WHEN5THEN'Silver'

    WHEN6THEN'Grey'

    WHEN7THEN'Green'

    WHEN8THEN'Yellow'

    ENDas [VehicleColour]

    FROM #RowGen

    CROSS...

    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: Database Design Follies: NULL vs. NOT NULL

    Zidar (3/10/2016)

    Somewhere at the begginig it was said that rows in a table (tuples in a realtion) represent only TRUE propositions (declarations). If 'a piece of data is unknown' 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: In a heap..

    Look at the missing index stats, index usage stats and index operational stats. SQL itself will help you determine the best clustered index, which should be your goal.

    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: Tables partition

    You'll get the most performance benefit by determining and implementing the best clustered index for that table, in this case very likely the date.

    But you might also gain some performance...

    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: Mystery data type conversion

    What is the data type for:

    sys_updated_on

    ?

    If it's smalldatetime/datetime/date/datetime2, then you should compare it to format YYYYMMDD, because that format is 100% universal across any/all SQL instances. The convert code...

    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 is a Table Scanned and Read So Much More than Others

    What is really critical is how the information table is clustered. Insure the table has the best clustering index to reduce rows to be read as much as 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".

  • RE: Database Design Follies: NULL vs. NOT NULL

    In the real world, there can be unknown values at a given point in time in a data store. For example, birth date. If you need to create...

    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: Database Design Follies: NULL vs. NOT NULL

    Zidar (3/2/2016)


    I am not done 🙂

    In T-SQL it takes two CHECK constraints to enforce the rule:

    C1: CHECK (NOT [Job] = 'DBA" OR [CertificateNum] IS NOT NULL)

    C2: CHECK ([CertificateNum] ...

    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: Database Design Follies: NULL vs. NOT NULL

    kenambrose (3/2/2016)


    [represent having no value]

    it was in earlier post. put nullable column into it's own table, enforce 1 to 1 relationship to parent table.

    no data for a row in...

    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: Database Design Follies: NULL vs. NOT NULL

    roger.plowman (3/1/2016)


    patrickmcginnis59 10839 (2/29/2016)


    roger.plowman (2/29/2016)


    I still don't see why relational tables can't have records for TBD, N/A, and UNK.

    If you need to know why a value is missing, you're going...

    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,381 through 4,395 (of 7,613 total)