Forum Replies Created

Viewing 15 posts - 661 through 675 (of 2,171 total)

  • RE: Removing partially duplicate records in SQL

    It's doable in one step.

    See here...

    DECLARE@Sample TABLE

    (

    recID INT IDENTITY(1, 1),

    col1 VARCHAR(1),

    col2 VARCHAR(2),

    col3 VARCHAR(3),

    userID INT

    )

    INSERT@Sample

    SELECT'A', 'B', 'C', 1 UNION ALL

    SELECT'A', 'B', '', 1 UNION ALL

    SELECT'A', '', 'C', 1 UNION ALL

    SELECT'F', '',...

  • RE: Start and End Date Groupings

    DECLARE@Sample TABLE

    (

    person INT,

    [Type] VARCHAR(20),

    id INT,

    [Start_Date] DATETIME,

    End_Date DATETIME,

    PRIMARY KEY CLUSTERED

    (

    person,

    [start_date],

    id

    ),

    grp int

    )

    INSERT@Sample

    (

    person,

    [Type],

    id,

    [Start_Date],

    End_Date

    )

    SELECT118007, 'ECAFSTD', 502858, '2007-09-10', '2007-09-10' UNION ALL

    SELECT118007, 'ECAFMTG', 503341, '2007-09-10', '2007-12-11' UNION ALL

    SELECT118007, 'ECAFSTD', 591228, '2008-02-05', '2008-02-05' UNION ALL

    SELECT118007, 'ECAFMTG', 598235,...

  • RE: Distinct Joined Insert

    INSERTNewTracks

    (

    AlbumID,

    TrackTitle,

    TrackPosition,

    TrackDuration

    )

    SELECTProductID,

    Title,

    Position,

    Duration

    FROM(

    SELECTAlbum.ProductID,

    Tracks.Title,

    Tracks.Position,

    Tracks.duration,

    ROW_NUMBER() OVER (PARTITION BY Album.ProductID ORDER BY ...) AS RecID

    FROMAlbum

    INNER JOINTracks ON Tracks.ProductID = Album.ProductID

    ) AS d

    WHERERecID = 1

  • RE: Table Variables and performance

    There you go! 🙂

    I learn something new every day...

  • RE: Table Variables and performance

    Jeff Moden (10/9/2008)


    G Bryant McClellan (10/8/2008)


    Michael,

    Ummm.... both table variables and temp tables start out in memory and "jump" to TempDB when they overcome some point in memory.

    Really?

    I was under the...

  • RE: Table Variables and performance

    Mostly with SQL Profiler and using the RowCount for 2005 and later, or integerdata for sql server 2000.

    Last year I was involved in a large project for performance tuning and...

  • RE: Table Variables and performance

    In my experience, the table variable flushes to disk when approx two pages has been filled.

  • RE: Parameter Sniffing with sp_ExecuteSQL ?

    Did you find the time to tset my suggestion, ie run the query manually vs the vendor-provided query?

    Was there a time difference? Was the plan different?

    I believe the query will...

  • RE: Parameter Sniffing with sp_ExecuteSQL ?

    This rewrite should produce the same result

    INSERT[#0ea9a6bfe6f948ce8ed5e5e1187f930c]

    (

    ResourceGuid

    )

    SELECTResourceGuid

    FROMCollectionIncludeResource

    WHERECollectionGuid = @collectionGuid

    UNION

    SELECTResourceGuid

    FROMCollectionMembership AS cm

    INNER JOINCollectionIncludeCollection AS cic ON cm.CollectionGuid = cic.SubCollectionGuid

    WHEREcic.CollectionGuid = @collectionGuid

    UNION

    SELECTw.GUID

    FROM#vResource AS w

    INNER JOIN(

    SELECT_ResourceGUID

    FROMInv_AeX_AC_Client_Agent

    WHERE[Agent Name] = 'Altiris...

  • RE: Is a cursor the best way to bulk insert to multiple tables with foreign key?

    What else do you have to uniquely identifi your importpersons?

  • RE: Return first record of each key

    According to sample data, this is what you need.

    SELECT Col1,

    Col2,

    ...

  • RE: Return first record of each key

    Will that work when records in table are stored in other order?

    old

    10203003275 D/C SET 0138 12/31/02 00086116 ...

  • RE: Slow SQL Calls

    something like this?

    SELECTSUM(CASE WHEN Status = 'A' THEN 1 ELSE 0 END) AS countReally,

    SUM(Points) AS OrdinarySum,

    SUM(CASE WHEN Status = 'B' THEN Points ELSE 0 END) AS casedSum

    FROMTable

  • RE: Return first record of each key

    SELECTCol1,

    Col2,

    Col3

    FROMTable1

    WHERECol3 > ''

    SELECTCol1,

    Col2,

    Col3

    FROMTable1

    WHERECol2 LIKE 'D/C SET%'

    Maybe if you post sample data like previous post we can help you more.

Viewing 15 posts - 661 through 675 (of 2,171 total)