Forum Replies Created

Viewing 15 posts - 1,186 through 1,200 (of 7,614 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]

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

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

  • Reply To: Replace Numbers

    Steve Collins wrote:

    Wow all that.  Ok maybe something like this

    select IcC.NumericValue,
    stuff((select ''+v.repl
    ...
  • 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...

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

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

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

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

  • 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, 4 months ago by ScottPletcher. Reason: Added "in batches" to make it clear what I intended there
  • Reply To: Replace Numbers

    Steve Collins wrote:

    Steve Collins wrote:

    maybe something like this

    select ic.NumericValue, 
    stuff((select '' + v.repl
    ...
  • 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...
  • 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...

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