Forum Replies Created

Viewing 15 posts - 1,186 through 1,200 (of 7,613 total)

  • Reply To: How to remove duplicate value from the rows in sql

    SELECT [File Name], [Created Date], MAX([File sending Date] AS [File sending Date]

    FROM <your_table_name>

    GROUP BY [File Name], [Created Date]

    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: Subquery issue in PIVOT

    I don't think you need PIVOT at all in this case, unless I'm not understanding correctly:

    SELECT Skill, COUNT(call_id) AS counts
    FROM [a2wh].[dbo].[vw_CallLogCommon_2021]
    WHERE date = '2021-10-10'
    GROUP BY Skill
    ORDER...

    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: Need advice with backup plan and transaction log file

    Am I wrong saying that immediatelly after the full backup, the transaction log is useless?

    Yes, that is quite wrong.

    The transaction log would still be needed to recover to a point-in-time...

    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: Replace Numbers

    Steve Collins wrote:

    To review, the table definition provided by the OP

    CREATE TABLE dbo.IntChange (NumericValue INT)

    INSERT INTO dbo.IntChange
    VALUES (15697)
    ,(876)
    ,(1452)
    ,(3374)
    ,(894)
    ,(84516)

    You have some reason to believe the future universe of 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".

  • Reply To: Replace Numbers

    Steve Collins wrote:

    Wow all that.  Ok maybe something like this

    select IcC.NumericValue,
    stuff((select ''+v.repl
    ...

    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: Replace Numbers

    I try not to mastermind someone else's needs for code.  If they confirm it's ssns or something else critical, then that needs to change.  Nothing about the ssn 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".

  • Reply To: Replace Numbers

    In general, I say replace only those chars that you the algorithm requires you to replace, leave all others alone.

    Otherwise, say 6 months from now, they decide to convert 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".

  • Reply To: Replace Numbers

    maybe something like this

    select ic.NumericValue, xml_string_agg.string
    from #IntChange ic
    cross apply (select stuff((select ''+v.repl
    ...

    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: Replace Numbers

    I do.

    Similarly, if, say, I were substituting letters l and 0 to prevent ambiguity, I'd simply replace just those, not 'A' with 'A', 'B' with 'B', etc.

    What about a potential...

    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: Replace Numbers

    Steve Collins wrote:

    ScottPletcher wrote:

    Your code also has zeros just disappear completely from your results.  It's never explicitly stated that zeros can't appear in these numbers.  Just in case they do, I...

    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: Replace Numbers

    Steve Collins wrote:

    ScottPletcher wrote:

    Is that code fundamentally different than the first query I posted using the same method?

    No temp table

    No Cartesian product without row goal, i.e. SELECT TOP(n)

    No LEFT JOIN

    No ISNULL

    The...

    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: Partitioning and Indexes needed on huge table

    Try different clustering for the table.  If that doesn't help enough by itself, then you can also look into partitioning the table.

    The key thing for determining the best clustered index...

    • This reply was modified 4 years, 8 months ago by ScottPletcher. Reason: Added "in batches" to make it clear what I intended 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: Replace Numbers

    Steve Collins wrote:

    Steve Collins wrote:

    maybe something like this

    select ic.NumericValue, 
    stuff((select '' + v.repl
    ...

    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: Replace Numbers

    IF OBJECT_ID('tempdb.dbo.#translations') IS NOT NULL
    DROP TABLE #translations
    CREATE TABLE #translations (
    from_char char(1) NOT NULL PRIMARY KEY,
    to_char...

    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: Creating appropriate data type from varchar(max)

    Yep, doing this yourself will be very complex.

    I would let SQL itself determine the type(s) in your situation.  This will involve an extra full load of the data.  Make every...

    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 - 1,186 through 1,200 (of 7,613 total)