Forum Replies Created

Viewing 15 posts - 1,366 through 1,380 (of 1,473 total)

  • RE: SQL COMPLEX QUERY - Urgent

    I'm afraid you're going to have to explain what you're looking for a little better. See the link in my signature for some tips on asking questions / posting...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Help needed filling in values based on previous row

    Probably:

    CPU

    Reads

    Writes

    Duration

    Number of total rows you are working with

    Number of rows being replaced by the function. (Number of NULLS)

    Nuber of rows in the final output.

    Execution plan

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Selecting specific characters from a column

    SELECT *

    FROM mytable

    WHERE SUBSTRING(mydata,10,1) = 'F' AND SUBSTRING(mydata,11,1) IN ('1','2','3','4','5')

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Limitations of @ - Local variable

    If you want multiple values in the list format you stated, you cannot. However, if you convert it to a local table variable and use that instead, you can...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Limitations of @ - Local variable

    Not entirely accurate:

    [font="Courier New"]USE NorthWind

    DECLARE @A TABLE(

    NameLetter VARCHAR(20))

    INSERT INTO @A(NameLetter)

    SELECT 'M' UNION ALL

    SELECT 'J'

    DECLARE @b-2 VARCHAR(20)

    SET @b-2 = 'R'

    DECLARE @C  VARCHAR(20)

    SET @C = 'First'

    SELECT *

    FROM Employees

    WHERE LEFT(FirstName,1) IN ( @b-2)...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Help needed filling in values based on previous row

    While my subquery seems to fit all that criteria, I'm not sure that it's creating a triangular join in this case. The subquery method is blazingly fast, it was...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: SQL library - best practices

    *considers a world without aliases*

    ...

    *dies a little inside*

    ...

    *goes to get a beer*

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: t-sql puzzler: column-wise table subtraction

    In re-reading this, it seems you only want to go 1(Rows from T1 not in T2) way, not both ways. That's even easier.

    I would do this as

    SELECT T1.*

    FROM Table1...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: t-sql puzzler: column-wise table subtraction

    This should be fairly easily accomplished with a couple of outer joins. Please post some table definitions / sample data according to the link in my signature and I'd...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Finding records based on a value from consecutive date records

    Thanks Matt, and good catch. I guess that's the downside of having perfectly ordered test data =).

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Help needed filling in values based on previous row

    Not allowed to use loops or cursors? I like that =). Add this after #DailyBalance is generated.

    [font="Courier New"]ALTER TABLE #DailyBalance

    ALTER COLUMN RowNum INT NOT NULL

    ALTER TABLE #DailyBalance

    ALTER COLUMN...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Finding records based on a value from consecutive date records

    This solution is a variation of Jeff Moden's Running Total Technique, which can be found here:

    http://www.sqlservercentral.com/articles/Advanced+Querying/61716/

    This is the setup for this solution, please post sample data in this fashion in...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Removing partially duplicate records in SQL

    Oh yeah, that's much better than letters =). Jeff might have been doing this for so long that he just intuitively grasps it all, but I still need my...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Effective way to execute multiple update statements (different where condition) on same table

    This still seems like a semi-poor way to do it, but I believe a very long case statement would probably beat out your 135 update statements.

    EG:

    UPDATE large_table

    SET...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • RE: Removing partially duplicate records in SQL

    And if you have something like:

    1 A B C

    2 A D...

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 15 posts - 1,366 through 1,380 (of 1,473 total)