Forum Replies Created

Viewing 15 posts - 3,376 through 3,390 (of 4,087 total)

  • RE: Row to column

    You can use UNPIVOT, but that gets very messy when you're trying to unpivot into more than one column. You would need three.

    You can also use CROSS APPLY to...

  • RE: Update with except conditon

    ChrisM@home (1/5/2012)


    drew.allen (1/4/2012)


    ChrisM@home (1/4/2012)


    say there are ten rows with the same VND_ID and only one of them matches the filter?

    You'll need to post sample data illustrating the problem and the...

  • RE: Update with except conditon

    ChrisM@home (1/4/2012)


    say there are ten rows with the same VND_ID and only one of them matches the filter?

    You'll need to post sample data illustrating the problem and the desired results.

    Drew

  • RE: Update with except conditon

    Actually, why are you using a subquery in the first place. Doesn't the following give you what you want?

    UPDATE PLU_1

    SET DSPL_DESCR = replace ([DSPL_DESCR],'"','in')

    WHERE AND DSPL_DESCR LIKE '%"%'

    AND len(replace...

  • RE: Update with except conditon

    The problem is that your REPLACE function is increasing the length of the string beyond the maximum allowed and you haven't correctly accounted for that fact. Given your subquery,...

  • RE: Query Question

    This is a presentation issue and is best handled in the presentation layer, not the database layer. You don't mention what you are using for your presentation layer, but...

  • RE: Get the delta records between 2 tables with same structure

    Welsh Corgi (12/31/2011)


    @Drew,

    You probably already know this but you can get a SQL Server 2008 R2 Developer Edition for under $50 USD.

    Yes, I already have it installed on my laptop...

  • RE: Problem with a simple Scalar UDF

    CELKO (12/30/2011)


    A function or a procedure is names with <verb>_<object> and does not have the meta-data like “udf_”; name things for what they are, not how they are implemented.

    Naming...

  • RE: Get the delta records between 2 tables with same structure

    If you just want the differences without updating, the easiest approach is to use the EXCEPT statement.

    SELECT [id], [name], [address], meter_flag, end_date

    FROM TableB

    EXCEPT

    SELECT [id], [name], [address], meter_flag, end_date

    FROM TableA

    This will...

  • RE: Get the delta records between 2 tables with same structure

    You're looking for the MERGE statement, which was introduced in SQL 2008. You can find more information in BOL. We still don't have SQL 2008, so I can't...

  • RE: How to get the max of records in row_number

    Evil Kraig F (12/29/2011)


    I wouldn't do this with Row_Number

    I would use Row_Number, because using MAX() in a subquery has the possibility of duplicate values if there are multiple records with...

  • RE: Format a Percentage

    Welsh Corgi (12/29/2011)


    drew.allen (12/29/2011)


    You realize that this is a presentation issue and is best handled in the presentation layer.

    Drew

    I guess that it depends because you may not always have a...

  • RE: Problem with a simple Scalar UDF

    I should mention another advantage of STUFF(). You're not cutting the string into pieces and reassembling them, so you don't have to worry about getting the pieces in the...

  • RE: Problem with a simple Scalar UDF

    I prefer using STUFF rather than SUBSTRING and concatenation for a couple of reasons:

    * It's language independent. The substring approach will fail if the language settings don't match...

  • RE: top 80 percent from sum

    cometav2011 (12/29/2011)


    I want to get the top 80% of a cumulative sum of a numeric field. Thanks but i have more than 1 mln rows and i am newbees....

Viewing 15 posts - 3,376 through 3,390 (of 4,087 total)