Forum Replies Created

Viewing 15 posts - 571 through 585 (of 1,923 total)

  • RE: Find Max , Min , Value in the SIngle Query

    How is this?

    ; WITH MaxValues AS

    (

    SELECT EEID , EFDT , DATA ,

    MaxRow = ROW_NUMBER() OVER(PARTITION BY EEID ORDER...

  • RE: how to group and rank (with reset)

    i guess a cute written cursor will smoke recursive cte here. But it will be interesting to see how quirky update works. should be stunning fast here...

  • RE: how to group and rank (with reset)

    For starters 🙂

    here is the sample data..

    IF OBJECT_ID ('#TempDB..#TempOne') IS NOT NULL

    DROP TABLE #TempOne

    GO

    CREATE TABLE #TempOne

    (

    ID INT PRIMARY KEY...

  • RE: how to group and rank (with reset)

    2 ways to do this,if there is an unique ID column.

    1. Recursive CTE - not a performant one; will be similar to the performance numbers of cursors or while loops.

    2....

  • RE: how to group and rank (with reset)

    Does your table an ID column to know the order of the rows?? Without that it is highly impossible to code this requirement. With ID column, this can achieved without...

  • RE: Query to Assign a Sequence Number

    Jeff Moden (11/19/2011)


    First, nicely done there Cold Coffee. I came up with an almost identical solution and saw yours when I was getting ready to post it. Your...

  • RE: Query to Assign a Sequence Number

    First the test data:

    IF OBJECT_ID('TempDB..#Table') IS NOT NULL

    DROP TABLE #Table;

    CREATE TABLE #Table

    (

    RecordSeq INT PRIMARY KEY CLUSTERED

    ,Account ...

  • RE: Incorrect syntax near 'GO'

    i see that you have posted in SQL 2005 forum, but can you confirm that u are running this query in SQL 2005? From SQL 2008, BACKUP LOG WITH TRUNCATE_ONLY...

  • RE: sql doubts

    A GROUP BY and HAVING COUNT(*) > 1 will give you what you want.

    And this is a cross post: Please redirect ur replies to : http://www.sqlservercentral.com/Forums/Topic1205657-392-1.aspx

  • RE: doubts in sql server

    A GROUP BY and HAVING COUNT(*) > 1 will give you what you want.

  • RE: Finding previous Saturday

    How about this?

    ; with numberofdays(n) as

    ( select 0 union all select 1 union all

    select 2 union all select 3 union all

    select 4 union all select 5...

  • RE: Complex update query

    Cadavre (11/10/2011)


    Keep it simple 🙂

    BEGIN TRAN

    CREATE TABLE #TABLE1 (ID INT, GroupA VARCHAR(10), GroupB VARCHAR(10), GroupC VARCHAR(10))

    INSERT INTO #TABLE1

    SELECT 1, 'True', 'False', 'True'

    UNION ALL SELECT 2, 'False', 'False', 'True'

    UNION ALL SELECT...

  • RE: Complex update query

    First lets set up some sample data:

    IF OBJECT_ID('TempDB..#TableA') IS NOT NULL

    DROP TABLE #TableA;

    CREATE TABLE #TableA

    ( ID INT

    ,GroupA BIT

    ,GroupB BIT

    ,GroupC BIT

    );

    INSERT INTO #TableA

    ...

  • RE: Duplicate Data in a Table

    Another way of doing it:

    WITH SampleData (UserName, UserID, DateCreated) AS

    (

    SELECT 'Mary Poppins', 123456, '12-07-05 14:23:45'

    UNION ALL SELECT 'Mary Poppins', 123456, '12-12-05 08:15:28' -- I want this one

    UNION ALL...

  • RE: Duplicate Data in a Table

    With 582 points and 1500 visits you must have known that the sample data in form of INSERT statement will make the life easier for the answerers. I also see...

Viewing 15 posts - 571 through 585 (of 1,923 total)