Forum Replies Created

Viewing 15 posts - 1,051 through 1,065 (of 3,957 total)

  • RE: Need to fill the Gaps with previous value

    Jeff - I see now how you manage to keep your post count so high. By working over time on holidays looking for old threads! 😛

    Interesting point about ISNULL...

  • RE: understanding the use of cross and outer apply operator

    You can also combine CROSS APPLY with Table Row Constructors to do cool things like an UNPIVOT.

    Refer to the first article in my signature links for more information.

  • RE: Concatenate column values as single value SQL Server 2008

    $w@t (11/27/2013)


    Try this

    declare @ColumnNameList VARCHAR(MAX)

    SELECT @ColumnNameList = COALESCE(@ColumnNameList +',' ,'') + ColumnName

    FROM

    <<table name>>

    select @ColumnNameList

    While this works for...

  • RE: extract the id's only

    This is pretty simple to do with a pattern-based string splitter like the one in the 4th article in my signature links:

    SELECT Item

    FROM tmp_id

    CROSS APPLY PatternSplitCM(Name, '[0-9]')

    WHERE [Matched]=1;

    If your names...

  • RE: Enter user-defined variables at runtime

    Change the PROCEDURE definition:

    create procedure sp_snapshot_create

    (

    @SS_Name varchar(100)

    )

    as

    declare

    @FileName_Datavarchar(50),

    @FilePathvarchar(200),

    @sqlvarchar(max),

    @datevarchar(10);

    Note that you should take a look at using sp_executesql instead of EXEC(@SQL) to avoid possible...

  • RE: How to parse connection strings on a column in SQL Server 2008

    You can expose pretty much any parameter you want regardless of position using a pattern-based string splitter like this:

    WITH SampleData (ID, ConnectionString) AS

    (

    SELECT 1, 'server=SVR1;database=DB1;uid=user1;pwd=pass1;enlist=true'

    ...

  • RE: Consecutive Row Number

    mickyT (11/27/2013)


    Hi

    Can I put this one up 🙂

    select personid, goaldate, goalstatus,

    row_number() over (partition by personid, goalstatus, g order by goaldate) * GoalStatus ConsecutiveGoals

    from (

    select personid, goaldate, goalstatus,

    row_number() over (partition...

  • RE: Join in two tables

    ankit.gupta1 (10/14/2013)


    I have two tables:

    T1 and T2.

    T1 has 1 row as

    name and age

    T2 has 2 rows as

    name, money1

    name, money2

    I use left outer join and get two rows in the resulting...

  • RE: Execute an sp for rows returned from a query

    Could you do something like this?

    CREATE TYPE T AS TABLE (C1 INT, C2 INT);

    GO

    CREATE PROCEDURE SP1 (@T T READONLY)

    AS BEGIN

    -- Do your validations, etc.

    ...

  • RE: table output

    Try this. If you can figure out what it is doing, you should be able to make the method work for your case.

    CREATE TYPE T AS TABLE (I INT);

    GO

    CREATE...

  • RE: Consecutive Row Number

    hunchback (11/27/2013)


    Your comment about the default for frame is not quiet right. If you specify the ORDER BY subclause but not frame in a function that can accept optional ROWS/RANGE...

  • RE: Consecutive Row Number

    hunchback (11/26/2013)


    The idea is similar but I hanged it a little bit to get the custom enumeration.

    Calculate the running total of GoalStatus = 0 by PersonId ordered by GoalDate. Calculate...

  • RE: Consecutive Row Number

    You can also do it with a Quirky Update (QU) but you'd need to add a PRIMARY KEY and an additional column to your #Goals table:

    CREATE TABLE #Goals (

    ...

  • RE: Consecutive Row Number

    csallen_01 (11/26/2013)


    No, if the next record is GoalStatus=0 the consecutiveCount goes to 0. Then the next record where GoalStatus=1 the consecutivecount goes to 1.

    This strikes me as inconsistent with...

  • RE: Extract string

    Need my morning coffee.

Viewing 15 posts - 1,051 through 1,065 (of 3,957 total)