Forum Replies Created

Viewing 15 posts - 12,931 through 12,945 (of 15,379 total)

  • RE: sql query help

    Like this?

    select top 1

    A.productID,

    B.surrogateID2,

    C.description

    from

    #tableB as B

    INNER JOIN #tableA as A on b.surrogateID1 = a.surrogateID1

    INNER JOIN #tableC as C on b.surrogateID2 = c.surrogateID2

    where

    b.surrogateID1 = (select max(b2.surrogateID1)

    ...

  • RE: Occurring columns named based on a local count variable

    You are welcome. Glad that worked for you. The code blocks especially are useful since it does a decent job of even keeping the color coding. We always appreciate the...

  • RE: Subquery help joins between subqueries.

    Nice job posting your desired output and what you have tried so far. Unfortunately there is little anybody can do without ddl (create table scripts) and sample data (insert statements)....

  • RE: Occurring columns named based on a local count variable

    mckennap (2/24/2012)


    I thought I was using dynamic sql. The same construct worked for defining the columns in an ALTER statement but does not seem to work in the UPDATE statement....

  • RE: Occurring columns named based on a local count variable

    mckennap (2/23/2012)


    Thank you very much. Mycolums were created named exactly how I wanted them. However, I now have a problem accessing the columns using variables. I need to update the...

  • RE: Creating sprocs from SP_EXECUTESQL

    Like Craig said, it is nearly impossible with the underlying tables to figure this out.

    I would suggest taking it out of the dynamic sql and see if the actual code...

  • RE: Update with select replace

    rabisco (2/22/2012)


    Each trip through your cursor it will update the ENTIRE table if @prereplace is null.

    More than anything else there is no need for a cursor. I will ask again...

  • RE: Need help on User define Function

    I hope you have better names than Function1, @parameter1, Table1 etc...

    Seems like just about every table has NOLOCK and is using index hints. How come?

    In case you never read about...

  • RE: Cursor Not Looping... ><

    From looking at this scaled down example I don't understand why you need a cursor and dynamic sql at all. It is just two insert statements.

  • RE: Update with select replace

    rabisco (2/21/2012)


    derek.colley (2/21/2012)


    It's updating all rows because what you are basically saying is for every row, set the bodytext equal to 'code=1' and concatenate other parameters onto it. If...

  • RE: Inserting data from one table into another table ordering by a datetime field

    gary.morey (2/21/2012)


    There actually is a clustered index on the TIME_STAMP column, and as you saw in the insert statement in my post I am using an ORDER_BY. So what...

  • RE: Update with select replace

    If you want some real help with please read the first link in my signature. It will explain how to ask questions and what kind of information to post.

  • RE: Inserting data from one table into another table ordering by a datetime field

    gary.morey (2/21/2012)


    I have a staging table (MergedDataStage1) that was populated by inserts from 2 tables. I now need to be able to insert the rows from this staging table...

  • RE: sql query help

    Take a look at the first link in my signature for best practices on posting questions. Basically you need to post ddl (create table statements), sample data (insert statements) and...

  • RE: Create Trigger using sproc

    GrassHopper (2/21/2012)


    Sean Lange (2/21/2012)


    You might want to add an IF EXISTS around both the create and drop statements. The way this is if you run it twice with the same...

Viewing 15 posts - 12,931 through 12,945 (of 15,379 total)