Forum Replies Created

Viewing 15 posts - 4,291 through 4,305 (of 7,619 total)

  • RE: Recreating tables from a list of tables

    cyp901 (5/31/2016)


    Andre 425568 (5/26/2016)


    I got fragmentation stats after the Table rebuild and then after index rebuild. Still had a lot of fragmentation.

    I believe what Jeff Moden was trying to say...

    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: Inline Table Functions with IF or Case Statement

    You can use derived tables within the query to provide computed values, you don't need variables.

    Also, here's a quick demo to show that you can query from different tables, 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".

  • RE: Inline Table Functions with IF or Case Statement

    djj (5/26/2016)


    ScottPletcher (5/26/2016)


    If the table structures to be returned are the same for all conditions, you can use UNION ALL with the appropriate WHERE conditions so that only one query...

    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: Need help identifying dates of an occurance after a specific date

    For up to 3 accidents total, it's relatively straightforward, with a single table pass for each table -- afaik, beyond 3 would require additional code/complexity (at least one additional join/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".

  • RE: SQL Date column issues in query

    You SET @startdate twice instead of setting @enddate 🙂

    ..

    set @startdate = '01-01-2016'

    declare @enddate datetime

    set @startdate = '10-10-2016' --should be set @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: Inline Table Functions with IF or Case Statement

    If the table structures to be returned are the same for all conditions, you can use UNION ALL with the appropriate WHERE conditions so that only one query ever returns...

    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: Arithmetic overflow calculating percentages

    What is the data type of "[SatisfiedPercentage]"? Because it's also part of the same CASE statement.

    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: aggregate for previous year specific date

    You might want to consider adding a flitered index on deceased date including the PatientNumber and DivisionCode. Then you can do an easy self-join, which I think should 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".

  • RE: Recreating tables from a list of tables

    Andre 425568 (5/23/2016)


    We found that fixing this brings fragmentation down by anything from 0-60 % after doing table rebuilds, after rebuilds we staill have fragmentation on tables and indexes. We...

    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: Summing with different GL Accounts into one row

    It looks like some columns are missing from the SELECT above, so I can't try to do the full query, but here's a general approach for using a lookup table...

    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: Not returning Table Name

    IF OBJECT_ID('tempdb.dbo.#DBDATATYPES') IS NOT NULL

    DROP TABLE #DBDATATYPES

    CREATE TABLE #DBDATATYPES

    (

    DbName nvarchar(128)

    ,TableName nvarchar (128)

    ,ColumnName nvarchar (128)

    ,Datatype nvarchar (128)

    )

    INSERT INTO #DBDATATYPES

    EXEC sys.sp_MSforeachdb '

    IF ''?'' IN (''master'', ''msdb'')

    ...

    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: YEAR TO DATE DATA

    SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, START_DATETIME), 0) AS START_MONTH,

    SUM(SALES) AS TOTAL_SALES

    FROM MY_TABLE

    WHERE START_DATETIME >= '20150101' AND START_DATETIME < '20150511'

    GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, START_DATETIME), 0)

    ORDER 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".

  • RE: Using computed Columns to Create another Computed Column

    Matthew Saggers-700210 (5/12/2016)


    Lowell, yes this is the way to go. I found when the compute is quite complex like

    A int

    B int

    c int

    D as A+B

    E as ((A+B) / c) /...

    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: Unique Indexes Are Code; Non-Unique Indexes Are Data

    orjan.franzen (5/6/2016)


    Having to drop an unique index to increase performance can be done easily with a generated script wether it's a primary key with clustered index or a unique 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: Unique Indexes Are Code; Non-Unique Indexes Are Data

    orjan.franzen (5/6/2016)

    The usage of unique indexes instead of declarative primary key constraints is just an old way of implementing entity integrity and should be avoided/forbidden if it's not for backwards...

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