Forum Replies Created

Viewing 15 posts - 1,276 through 1,290 (of 1,957 total)

  • RE: Turn negative numbers into 0

    SQLkiwi (7/18/2011)


    CTEs generally don't help - the expression is evaluated twice.

    I included the TOP trick as the only way I know to force the query processor to evaluate just once.

    Here...

  • RE: Need help

    Forgetting about the table issues, here is a way to convert minutes to hh:mm format:

    declare @time numeric(10,2)

    set @time = 97.10

    select convert(char(5),dateadd(minute,@time,0),8)

    Of course, dateadd takes an integer for the increment, so...

  • RE: Single table row-column comparison issue

    Is this what you are looking for?

    You may need to tweak the EXISTS statement to handle InventoryIDs that have more than 1 digit...

    ;with data(DrugID, InventoryID)

    as

    (

    select 'MAGN2IVPB','FLR-4N' union all

    select 'MAGN2IVPB','FLR-5N' union...

  • RE: loops

    The Dixie Flatline (7/11/2011)


    If anyone would post up some examples where a cursor solution outperforms a set-based solution, I will look at them respectfully.

    Bob

    This brought back memories of a thread...

  • RE: Handle NULLs

    My latest submission is based on the string manipulation, but simplified... on my QUAD core PC I like the results, but let's see how it does on yours.

    I borrowed the...

  • RE: Handle NULLs

    Wow! that shows how slow my isnull/nullif/apply method is!

  • RE: copy large blob table

    Bulk logged with select into will make a difference, yes - don't use insert into.

    You have to remember though that with that setup, you are going to thrash the disk...

  • RE: copy large blob table

    Does the target database have pre-allocated storage large enough to store the data?

    Are the databases stored on different hardware or the same?

    What is the maximum throughput of the storage system?

    Have...

  • RE: copy large blob table

    Where are you transferring the data to? Same database, different database, same server, different server?

    What is the table definition?

  • RE: Handle NULLs

    mikes84 (7/6/2011)


    I have a situation where I'm querying two tables, each that has up to two hobbies listed. The first table has hobby1 and hobby2, and the second table has...

  • RE: Help with importing of a XML File

    pbyrum (7/7/2011)


    It appears the code will take the whole file and place it into a column in the table.

    I am looking for is taking the data in the XML file...

  • RE: SQL Update Behaviour

    SQLkiwi (7/7/2011)


    mister.magoo (7/7/2011)


    With the PRIMARY KEY defined, the query plan shows a SORT DISTINCT which results in 1 row from the join of the two tables, and seemingly this result...

  • RE: SQL Update Behaviour

    I don't know if anyone has actually answered the question about why the two results are different...

    With the PRIMARY KEY defined, the query plan shows a SORT DISTINCT which results...

  • RE: Handle NULLs

    tommyh (7/7/2011)


    Using your excellent testdata i came up with

    select

    SubString(s, 1, 20),

    SubString(s, 21, 20),

    SubString(s, 41, 20),

    SubString(s, 61, 20)

    from...

  • RE: Select only Names with more than one assigned ID

    Is this what you are after?

    SELECT AA.AgencyName,AA.AgencyID

    FROM (

    SELECT CA.AgencyName, CA.AgencyID, COUNT(*) OVER(PARTITION BY CA.AgencyName) AS AgencyIDCount

    FROM ContactAction AS CA

    GROUP BY CA.AgencyName, CA.AgencyID

    ) AS AA

    WHERE AA.AgencyIDCount>1

    ORDER BY AA.AgencyName

Viewing 15 posts - 1,276 through 1,290 (of 1,957 total)