Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Burbank & Santa Cruz de la Sierra
    Posts
    3,716

    Talking Unanswered: Inserting from a distinctly easy select...*snicker*

    Hi all...I have taken a look at an archive search, and continue to research and play with mysel...errr...my select, but in the meantime...what am I missing?!?!?!

    Here is my excruciatingly interesting insert statement
    Code:
    INSERT INTO dbo.WON_MutualFundNames
    SELECT UPPER(FndTickerSym), FndName
    FROM L_WONDA_MUTUALS.wondb.dbo.funds 
    WHERE FndTickerSym LIKE '[A-Z]%[X]'  	/* first char is A thru Z and last char is X	*/
    GROUP BY FndTickerSym, FndName
    Everything works just hunky-dory, EXCEPT for...two @#$(*#& rows in my database table:
    Code:
    FndTickerSym     FndName
    -------------     -------------------------------
    DHMBX              DREYFUS YIELD MUNICIPAL BOND
    dhmbx              DREYFUS YIELD MUNICIPAL BOND
    What has befuddled me is that when I run the SELECT by itself, only ONE of the rows is returned - - only when I combine it with the insert, I get a duplicate primary key value error (the FndTickerSym is the insert-table's primary key column).

    WTF is goin' on, dudes? And perhaps more importantly, how can I get around it?

    Any suggestions are welcome

    well...any except "delete the duplicate row", which I am already crafting an email about to send to the offending/offensive (I assure you, they are both) group that maintains the data in this table. However, whenever I make my database idiotproof, they always invent a craftier idiot...so I must code the insert to work if such a situation presents itself again in the future.

    Thoughts? Suggestions? New Cursewords?
    aka "Paul"
    Non est ei similis.

    I just read "100 Things To Do Before You Die". I was surprised that "Yell for help!!" wasn't one of them

  2. #2
    Join Date
    Jan 2005
    Location
    Green Bay
    Posts
    201
    Try grouping by UPPER(FndTickerSym)

    This insert is inserting an upper case record as upper
    then inserting a lower can record as upper
    hence duplicate entry.

  3. #3
    Join Date
    Feb 2004
    Location
    Burbank & Santa Cruz de la Sierra
    Posts
    3,716

    *blush* ummm...nevermind.

    *blush*

    trouble wasn't with this row...there were two others with duplicate symbols and different descriptions. *hanging head*

    ummmm...

    nevermind.

    *sigh*
    Last edited by TallCowboy0614; 12-20-05 at 16:23.
    aka "Paul"
    Non est ei similis.

    I just read "100 Things To Do Before You Die". I was surprised that "Yell for help!!" wasn't one of them

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •