Forum Replies Created

Viewing 15 posts - 3,976 through 3,990 (of 4,080 total)

  • RE: insert row in a table inside another database and get identity back

    It works fine on my 2005 development box. What does your exec statement look like in the other db you run this proc from?

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: insert row in a table inside another database and get identity back

    OUTPUT works wonderfully for that purpose, although an example in books online used to suggest the opposite. It's very easy to implement. Check out this example:

    ---------------------------------------------------------------------------

    declare...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: duplicate key error

    UPDATE and INSERT are mutually exclusive operations. You either run an update OR an insert query. Updates overwrite existing information, and will not produce the...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: duplicate key error

    That is exactly the problem. If you have a customer 12345 already in your table, you can't insert a second customer with 12345. If you...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: duplicate key error

    Five different columns that all have a value of 2 would not create the problem. Five different rows that all have a value of 2 in the primary...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Exporting resultset of temp table to other formats. How?

    Doh! :w00t:

    I knew there had to be a better way. What I really like about this approach is that you could use it for...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Exporting resultset of temp table to other formats. How?

    OK... I'm assuming you need the result set for subsequent processing, not just generating it for a download. (If that assumption is wrong and all you want to...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: SQL Server 2005 Pivot Table Usage? Or maybe another approach...

    I think you can get there. Basically you have to write code that creates a dynamic SQL string similar to the one in the example, and then execute...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Exporting resultset of temp table to other formats. How?

    My kneejerk response was BCP, but you're talking about a temporary table. Is the file small enough that you could just copy it briefly to a "permanent" table,...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: How to Copy a record in the same table and modify some columns.

    Guys, you're still not addressing his issue. He wants to insert deleted rows back into the same table with a version identifier, using SELECT * because he doesn't...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: There must be a better way

    Looks good to me. 🙂

    I'm deleting my earlier entry to plug in the commas.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: How to Suppress Missing Commit or Rollback Errors?

    I don't have an answer for you because I've never had that as a requirement, but I do have a question:

    What is supposed to happen if the second application (that...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Problem washing a list with another list

    You are correct, it is the existence of a null from your subquery that is causing your query to return no rows. It is easy enough to fix...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Need help displaying verticle data horizontally.

    select invNo,productID

    ,sum(case when sizeSeq = 1 then quantity else 0 end) as SizeSeq1

    ,sum(case when sizeSeq = 2 then quantity else 0 end) as SizeSeq2

    ,sum(case when sizeSeq = 3 then quantity...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: How to Copy a record in the same table and modify some columns.

    rd (11/7/2008)

    SELECT * INTO #T FROM deleted

    UPDATE #T SET ID=NewID();

    INSERT dbo.tblAgencies SELECT * FROM #T --(1)--

    Two questions:

    (1) Does the deleted table contain rows which have been deleted from...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

Viewing 15 posts - 3,976 through 3,990 (of 4,080 total)