Forum Replies Created

Viewing 15 posts - 8,341 through 8,355 (of 8,731 total)

  • RE: Common Table Expression - Is this consider a recursive code being called twice?

    With UNION of 2 statements above, does this mean recursive being called twice or was it just one?

    Yes, you can check the execution plan.

    another word where in the code...

  • RE: Avoid using cursors

    Yes, and there's a better way for you to post the question so we can help you.

    If you give us DDL, Sample Data and Expected Results, we'll be able to...

  • RE: Group by column A but compare column B

    I would like to know more about those methods. Could you tell me where to find information? I couldn't find much.

    This is what I came with. It's doing many reads.

    DECLARE...

  • RE: Table Relationships

    For the many to many relationship, I might have a better example. I'm not sure if it's commonly used, but I've seen it.

    If you have invoices and payments in a...

  • RE: Group by column A but compare column B

    I found a way to do this. Might not be optimal but it's a way.

    However, I want to know what is this for, as Craig asked.

  • RE: String or binary data would be truncated.

    Sean Lange (9/27/2012)


    Luis Cazares (9/27/2012)


    I disagree, varchar can hold up to 8000 characters in 2000 (nvarchar will only hold up to 4000, though).

    http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx

    Another option is to use text columns

    Doh!!! You...

  • RE: Table Relationships

    I have questions regarding foreign key and about parent-child relationship:

    1. What is the purpose of self referential foreign keys ? or why do we create it?

    To make a reference to...

  • RE: String or binary data would be truncated.

    I disagree, varchar can hold up to 8000 characters in 2000 (nvarchar will only hold up to 4000, though).

    http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx

    Another option is to use text columns

  • RE: where clause error

    anthony.green (9/27/2012)


    WHERE

    ISNULL(SUM(BF.GLOBAL_FEE_TAKEN), 0.00) < ISNULL(SUM(BF.FEE_AMOUNT), 0.00)

    Shouldn't that be on the HAVING clause (after the GROUP BY)?

  • RE: previous figure

    Could you use something like this?

    If it works, do you understand it?

    ;WITH CTE AS(

    selectcalcid,

    salesamount,

    productid,

    ROW_NUMBER() OVER( PARTITION BY productid ORDER BY calcid) rn

    from #abc t1

    --where productid IN (58, 62, 65)

    )

    SELECTcte1.productid,

    cte1.calcid,

    cte1.salesamount,

    cte2.calcid...

  • RE: Query Help

    Both tables are far to large as this is a running system to give a copy, I am just trying to create a query for a report.

    That's why you're asked...

  • RE: Case in where clause doesn't get validated

    Something similar to Lowell's but I believe he missed something.

    AND NextReviewDate >= CASE WHEN @Due = 'Over Due' THEN '19000101'

    WHEN @Due = 'Due In 30 Days' THEN GETDATE()

    WHEN...

  • RE: sex max vale of a recod

    It seems that I like the other solutions better than mine.

    Laurie, you should drop the else from your cases to allow negative numbers.

    Mine won't work when all the flags are...

  • RE: sex max vale of a recod

    With some help from this article from Dwain, I came up with a solution:

    An Alternative (Better?) Method to UNPIVOT (SQL Spackle)[/url]

    WITH Original AS( SELECT ROW_NUMBER() OVER( ORDER BY (SELECT NULL))...

  • RE: Interesting query - remove duplicates from my table

    Sean Lange (9/26/2012)


    Are you sure that works?

    For me it has errors. There's no such thing as "DELETE field FROM Table" as it will delete the entire row. And AFAIK you...

Viewing 15 posts - 8,341 through 8,355 (of 8,731 total)