Forum Replies Created

Viewing 15 posts - 2,251 through 2,265 (of 7,613 total)

  • Reply To: SQL agent job stuck

    Recompile forces SQL to recreate the query plan, even if one is already available in memory.

    That process may require updating stats if one of the tables in the query has...

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

  • Reply To: Clustered Indexes on GUIDS, Complex chains of triggers and Heaps

    david.edwards 76768 wrote:

    ... The other thing is,  all the other tables have clustered indexes on the GUID PKs ...

    That alone might have made me skip buying the product!

    Fillfactor also depends on...

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

  • Reply To: Unique Index ~ SQL server

    CREATE UNIQUE INDEX UK_IDX_TLOG ON TLOG_TB ( TXN_AUTH_ID ) WHERE MSG_TYPE = '200';

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

  • Reply To: Find run of repeating value

    vliet wrote:

    It can not use the run length as a parameter, because the window specification requires a literal value.

    But for every given run length a solution exists using only six...

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

  • Reply To: Find run of repeating value

    jcelko212 32090 wrote:

    >> I want to find runs of at least three 1s, and return the result below. The 0s would be any test_values that are not 1. <<

    Since SQL does...

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

  • Reply To: convert table row into colunm

    As Phil noted, I can't actually test the code, since you didn't provide any directly usable data:

    SELECT up.class, up.model, ca1.type
    FROM dbo.u_parts up
    CROSS APPLY ( VALUES([W20-13]),([W20-14]),([WorkLog]) ) 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".

  • Reply To: Trim trailing characters from a varchar?

    Glad it helped, thanks for the feedback!

    If you need to split out the final string, you can use a tally table for that:

    ;WITH
    cte_tally10 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".

  • Reply To: Find run of repeating value

    Yet another version.

    Non-serious note to Jeff Moden: See, I actually am willing to use an identity as the clustering key.

    DECLARE @min_vals_in_sequence int
    SET @min_vals_in_sequence = 3

    DROP TABLE IF...

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

  • Reply To: How to extract string between variable characters?

    If you need both extracted values in the same row:

    SELECT s.StuffId, ds2.email_name_1, ds2.email_name_2
    FROM #Stuff s
    CROSS APPLY (
    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".

  • Reply To: Trim trailing characters from a varchar?

    I think this will do it:

    SELECT REPLACE(string, '000', '')

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

  • Reply To: convert scalar function to table valued function

    tanehome wrote:

    ScottPletcher wrote:

    This code does include the date swap if they pass in a DateFrom that is greater than the DateTo.

    if i need it to does not include date swap,...

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

  • Reply To: SQL database compression before shrink ?

    Do you use secondary filegroups?  If you do, I'd create a new filegroup and files and do the data compression into that new filegroup.  Then you can shrink the original...

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

  • Reply To: DB Space Script - Arithmetic Overflow

    ...

    sum(CAST(size AS bigint))/128.0 AS File_Size_MB,

    sum(CAST(FILEPROPERTY(name, ''SpaceUsed'') AS bigint))/128.0 as Space_Used_MB,

    SUM(CAST(size AS bigint))/128.0 - sum(CAST(FILEPROPERTY(name,''SpaceUsed'') AS bigint))/128.0 AS Free_Space_MB

    ...

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

  • Reply To: convert scalar function to table valued function

    OOPS, yeah, I forgot about the cross-db reference.  I should not have put SCHEMABINDING in there.

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

  • Reply To: Self referencing formula has me stumped

    Here's how to calc the new selling price for any new net margin.  (I always did love algebra.)

    Edit: I didn't see Des's until after I had posted mine.

    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 - 2,251 through 2,265 (of 7,613 total)