Forum Replies Created

Viewing 15 posts - 2,221 through 2,235 (of 3,957 total)

  • RE: Tally Calendars and 'Week 1'

    Jason-299789 (1/8/2013)


    Final Edit,

    Dwain, I figured out why yours didnt work you're addind on the Julian day which is 1-365/366

    I think you need to add the Week day number...

  • RE: How to extract the paricular values from a string

    Or, even simpler:

    WITH Filenames (fn) AS (

    SELECT 'XX_YYYYY_AA_BBB_SampleTransaction_120807_55322.TXT'

    UNION ALL SELECT 'XX_YYYYYY_DDD_MasterTransaction_120807_00005.TXT')

    SELECT fn=LEFT(fn, PATINDEX('%[0-9]%', fn)-2)

    FROM Filenames;

  • RE: How to extract the paricular values from a string

    sqlstud (1/8/2013)


    dwain.c (1/8/2013)


    Here are two ways:

    WITH Filenames (fn) AS (

    SELECT 'XX_YYYYY_AA_BBB_SampleTransaction_120807_55322.TXT'

    UNION ALL SELECT 'XX_YYYYYY_DDD_MasterTransaction_120807_00005.TXT')

    SELECT fn=SUBSTRING(fn, 1, CHARINDEX('.', fn))

    FROM Filenames;

    WITH Filenames (fn) AS (

    SELECT 'XX_YYYYY_AA_BBB_SampleTransaction_120807_55322.TXT'

    UNION ALL SELECT 'XX_YYYYYY_DDD_MasterTransaction_120807_00005.TXT')

    SELECT fn=Item

    FROM Filenames

    CROSS APPLY...

  • RE: Connecting to multiple sql servers

    alex 64682 (1/7/2013)


    Many thanks for all the responses. I haven't encountered Openrowset before but it looks like the best option. Not entirely sure where to place the remote IP Address,...

  • RE: Tally Calendars and 'Week 1'

    CELKO (1/7/2013)


    I would build a calendar table with a ISO-8601 week-within-year format column in addition to the usual Common Era date. This format is 'yyyyWww-d' where yyyy is the year,...

  • RE: Generate Months from unique records with different date ranges

    Jason-299789 (1/8/2013)


    Id love to see the GenerateCalendar function.

    Coming from a DW background the persisted calendar table is second nature, and I'm surprised more traditional OLTP systems dont implement...

  • RE: How to extract the paricular values from a string

    Here are two ways:

    WITH Filenames (fn) AS (

    SELECT 'XX_YYYYY_AA_BBB_SampleTransaction_120807_55322.TXT'

    UNION ALL SELECT 'XX_YYYYYY_DDD_MasterTransaction_120807_00005.TXT')

    SELECT fn=SUBSTRING(fn, 1, CHARINDEX('.', fn))

    FROM Filenames;

    WITH Filenames (fn) AS (

    SELECT 'XX_YYYYY_AA_BBB_SampleTransaction_120807_55322.TXT'

    UNION ALL SELECT 'XX_YYYYYY_DDD_MasterTransaction_120807_00005.TXT')

    SELECT fn=Item

    FROM Filenames

    CROSS APPLY PatternSplitCM(fn, '[0-9a-zA-Z_]')

    WHERE...

  • RE: Generate Months from unique records with different date ranges

    Jason-299789 (1/8/2013)


    Nice Alternative dwain, love the use of cross applys with the tally and inline month generator, as well as the normalisation of the month to always be the first....

  • RE: Initialisation file

    Why not use:

    TRUNCATE TABLE tblIDNames

    Instead of:

    DELETE FROM tblIDNames

  • RE: atomic value update?

    aerojockey (1/7/2013)


    I have an application that needs to make an atomic update to an item in a table. It has to read the value, do something complicated to it,...

  • RE: Generate Months from unique records with different date ranges

    If you don't want to create a calendar table, you can do this (which really just creates the calendar table on the fly).

    CREATE TABLE #Contracts

    (

    ContractNumber INT

    ,ContractStartDate DATETIME

    ,ContractEndDate DATETIME

    ,ContractAmount MONEY

    );

    INSERT INTO...

  • RE: Double Counting and Sign Reversals

    ericwood8 (1/7/2013)


    First off, I love this article.

    On Sign Reversals section, imagine that entry 7 & 8 were $500 instead of $400. :

    UNION ALL SELECT 500, '+' --...

  • RE: Double Counting and Sign Reversals

    bthomson (1/7/2013)


    you used a custom table value function called DelimitedSplit8k

    probably works like most splits but... just thought you should know.

    Hi bthomson! Thanks for dropping by.

    There is a link in...

  • RE: I need help with my query. I found part of this, but doesn't work. Please help.

    Here is the FUNCTION referenced in the article. Copy/paste this code into an SSMS window on your database and execute the script.

    -- PatternSplitCM will split a string based on...

  • RE: Compare one row with another in a Table !

    Agreed that not sure why you wouldn't want to use a CTE, but here's another alternative.

    DECLARE @H TABLE

    (House_Acc INT, Accountid INT, repcode VARCHAR(10))

    INSERT INTO @H

    SELECT 123,...

Viewing 15 posts - 2,221 through 2,235 (of 3,957 total)