Forum Replies Created

Viewing 15 posts - 781 through 795 (of 1,246 total)

  • RE: Random number generation based on condition

    This sounds like one of those odd-nut problems that is most easily handled w/ a "quirky" update.

    Before using this method in any kind of production code make sure you read...

  • RE: Converting time - from "seconds after midnight"

    tacy.highland (12/2/2016)


    The only thing I have against these nice simple answers:

    REPLACE(RIGHT(CONVERT(CHAR(19),DATEADD(ss,@Time,0),100),7),' ','0')

    and

    CONVERT(varchar(20), CONVERT(time, DATEADD(SECOND, @time, CONVERT(datetime, CONVERT(date, getdate())))), 100)

    ...is that they appear to display the time as 07:30PM rather...

  • RE: Converting time - from "seconds after midnight"

    Another option...

    WITH

    n (n) AS (SELECT 1 FROM (VALUES (1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) n (n)),

    cte_Tally (n) AS (

    SELECT TOP 86399-- 86400 would be midnight of the following day...

    ROW_NUMBER() OVER (ORDER BY (SELECT...

  • RE: how to retrieve numbers from a string

    Alan.B (11/28/2016)


    Of that only works with the "numbers dash numbers dash letters" formatting.

    Plus it boring... My "just for the fun of it" solution answered (what I thought) was a more...

  • RE: how to retrieve numbers from a string

    Alan.B (11/28/2016)


    Assuming Jason's interpretation of the OP's requirement is correct and the requirement was to have all the numbers in a single column separated by spaces (which looks correct but...

  • RE: how to retrieve numbers from a string

    Just for the fun of it...

    Here's a function that'll remove all non-numeric values and place a single space between non-contiguous groups of numbers (not dependent on any specific pattern...

  • RE: Locking a table while being refreshed

    Here is another "Zero downtime" option that uses partition switching.

    See the inline comments for the details...

    USE tempdb;

    GO

    --=============================================================================

    -- Create the "original" table and populate it

    IF OBJECT_ID('dbo.OriginalTable', 'U') IS NOT NULL

    DROP...

  • RE: How to add multiple values to a parameter

    CELKO (10/10/2016)


    I have a table of statuses(Open, Closed, etc.). I need to create a parameter that combines the first letter of multiple statuses, such as any status beginning with...

  • RE: Extract a uniform pattern from a file path

    Looks like a time code (fixed at 14 characters)... The following will work even if the file path changes...

    DECLARE @input VARCHAR(1000) = '\\cc0dware01\BMF\RMS\REBATERATES-WORKING-2016ToEnd08-20160905180112.csv';

    SELECT output = LEFT(RIGHT(@input, 18), 14);

  • RE: Beginner stuck again could use some help

    Sounds like a goofy assignment... There's no logical reason to use a CTE for this request... It just creates code clutter...

    In any case it's simple enough to accomplish... but... like...

  • RE: "Add" Hyphen Data Modification

    eandre360 (10/9/2016)


    Eirikur Eiriksson (10/9/2016)


    Quick example, clean the string and stuff it with hyphens

    😎

    Thanks Eirikur. Unfortunately, I won't be able to hardcode my. Need to figure out a way to either...

  • RE: Splitting a multi-delimiter string and update

    Here's another option that actually updates the original table...

    IF OBJECT_ID('tempdb..#TableName', 'U') IS NOT NULL

    DROP TABLE #TableName;

    CREATE TABLE #TableName (

    Company INT NOT NULL,

    OrderNum INT NOT NULL,

    OrderLine INT,

    Part CHAR(3) NOT NULL,

    LineDesc...

  • RE: Select all child nodes

    Try it like this...

    SELECT Id ,

    XmlCol.query('./fullname').value('.', 'nvarchar(max)') AS 'fullname'

    FROM @t t

    ...

  • RE: Splitting a multi-delimiter string and update

    There's probably a way to do this w/o taking 3 passes at the table but it's not jumping out at me at the moment...

    In any case this should get you...

  • RE: Monthly total of active data

    Sorry... I missed the expected output...

    A simple modification gets the desired results...

    DECLARE

    @BegDate DATE = '2016-01-05',

    @EndDate DATE = '2016-06-22';

    WITH

    n (n) AS (SELECT 1 FROM (VALUES (1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) n (n)),

    cte_MonthStart...

Viewing 15 posts - 781 through 795 (of 1,246 total)