Forum Replies Created

Viewing 15 posts - 5,476 through 5,490 (of 7,619 total)

  • RE: Backups have more than doubled in size

    Were the backups using compression before and are did not use compression last time for some odd reason?

    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: Cache question - sys.dm_exec_procedure_stats

    The complexity of the plan is also a factor in how much SQL weights keeping a plan in cache (by assigning more complex plans higher initial values).

    Also, I believe ad-hoc...

    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: Is there a better way to write this query.

    curious_sqldba (1/13/2015)


    ScottPletcher (1/13/2015)


    You don't need to re-count the rows every time.

    DECLARE @BatchSize int

    DECLARE @RowRount int

    DECLARE @TableRowCount int

    DECLARE @TableRowLimit int

    SET @BatchSize = 10000

    SELECT @TableRowCount = COUNT(*)

    FROM PtActs WITH (NOLOCK)

    SET @TableRowLimit...

    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 question

    RHJ (1/13/2015)


    I have a working version of this that is limping along by using a UniqueSession table as a bridge between Locations and Sessions. My boss is unhappy 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: Database design question

    Technically you should still be dealing with a logical not a physical design, i.e. "entities" rather than "tables". but let's jump ahead to tables anyway, I guess.

    You're missing at least...

    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: New column in Existing table and uploading data

    I'd try instead to just:

    (1) just in case, as a backup, copy existing key column(s) and data column to be changed to a keyed backup table

    (2) verify that existing data...

    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: Is there a better way to write this query.

    You don't need to re-count the rows every time.

    DECLARE @BatchSize int

    DECLARE @RowRount int

    DECLARE @TableRowCount int

    DECLARE @TableRowLimit int

    SET @BatchSize = 10000

    SELECT @TableRowCount = COUNT(*)

    FROM PtActs WITH (NOLOCK)

    SET @TableRowLimit = 10050000

    WHILE...

    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: Lowest of a few dates

    The VALUES clause simplifies it considerately, which can be great for longer lists:

    CROSS APPLY (

    SELECT MIN(date)

    FROM (

    ...

    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: Correlated Subquery?

    SQLSACT (1/9/2015)


    SELECT sku, product_description,

    (SELECT plant_nbr

    FROM ProductPlants AS B

    WHERE B.sku =...

    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 create a dynamic update statement based on return values in a select statement.

    DECLARE @sql varchar(max)

    DECLARE @column_list varchar(max) --as returned by first query

    SET @column_list = 'age,sex,race' --for example

    SET @sql = 'UPDATE tbl2 SET col2 = [' + REPLACE(@column_list, ',', ']+[') + ']'

    PRINT...

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

    I suspect recursion would be great for this, but that's not my specialty. This is somewhat akin to the earlier LOJ version, which unfortunately I didn't see until now...

    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: group by part of string

    Eric M Russell (1/9/2015)


    ScottPletcher (1/8/2015)


    You could also GROUP directly on the CASE expression itself:

    SELECT

    CASE

    WHEN message_text LIKE...

    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: dbcc dbcc show_Statistics question

    GilaMonster (1/9/2015)


    Table is empty. No rows in the table means that the statistics objects are empty.

    Not necessarily true -- a given index can be empty even if the table 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: group by part of string

    You could also GROUP directly on the CASE expression itself:

    SELECT

    CASE

    WHEN message_text LIKE '%ThePartToGroupBy%' THEN '%ThePartToGroupBy%'

    ...

    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: Dynamic Query

    Might as well have max flexibility on the number of name levels provided:

    DECLARE @tablename varchar(500)

    DECLARE @sql varchar(8000)

    SET @tablename = 'YourTableName'

    --SET @tablename = 'server1.db1..YourTableName'

    SET @sql = 'SELECT * FROM '...

    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 - 5,476 through 5,490 (of 7,619 total)