hi all

    Date: 12/03/06 (SQL Server)    Keywords: sql

    Hello,

    This is my first time posting here. I'm pretty new at SQL but I think that I am learning. :) Anyway, I have a sort of issue that I am hoping someone can clarify for me.

    At my job, I am trying to fix up a query someone else made, forcing it to have all unique "PSourceIDs." Obviously, I can get 2 of the same number if I select distincts and then have two entries with different values anywhere in the record. So, here is what I was trying to do, eventhough it fails when I run it:


    drop table #NewTest
    select distinct psourceid into #NewTest
    from #Test T
    select * from #NewTest

    insert into #NewTest (Priority, COSupplierCode, Aging, AgingToNow)
    select Priority, COSupplierCode, Aging, AgingToNow
    from #Test T
    where (T.psourceid = #NewTest.psourceid)
    select * from #NewTest


    Firstly, can I do this with temp tables, and secondly, if so, then where did my logic fail?

    Source: http://community.livejournal.com/sqlserver/54245.html

« SQL Server 2005: A database... || Sql 2000 to 2005 learning... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home