Forum Replies Created

Viewing 15 posts - 2,101 through 2,115 (of 2,169 total)

  • RE: Pivot table for Microsoft SQL Server

    You're welcome!

    Now I have to look up "arduous" in my dictionary...

  • RE: Pivot table for Microsoft SQL Server

    Max number of columns are restricted to what datatype you use for #Aggregate column. The total size for a row is 8,060 bytes. Using 60 bytes for RowText leaves us...

  • RE: Cursor not ordering data correctly?

    Why would you want to have a cursor looping through all records when it almost certainly can be done set-based?

    When reading your code, it seems to me that you want...

  • RE: remove trailing zeros

    If data are stored as floating point, use

    declare @num table (i float)

    insert @num

    select 134.000 union all

    select 1.1200 union all

    select 100.00 union all

    select 0.0200

    select i,

     convert(varchar,...

  • RE: Need SQL to display all relationships in database

    Even if there are no Cascades deleted, there might still exist triggers!

  • RE: Group by ..

    Use a derived table, such as

    SELECT  CompanyID,

      Contacted_Date,

      FollowUp_Date

    FROM  MyTable

    INNER JOIN (

       SELECT  CompanyID,

         MAX(Contacted_Date) theDate

       FROM  MyTable

       GROUP BY CompanyID

      ) z ON z.CompanyID = MyTable.CompanyID AND z.theDate = MyTable.Contacted_Date

  • RE: don''''t know how to use a cursor to insert rows from one table to another elinimating dups

    So following code will not work?

    SELECT  web_note_1.CC025_ORG_CODE,

      web_note_1.CC025_EXT_ACCT_CODE,

      web_note_1.CC025_NOTE_CLASS,

      web_note_1.CC025_PROD_CODE

    LEFT JOIN TEMP_WEB_NOTES ON TEMP_WEB_NOTES.CC025_ORG_CODE = web_note_1.CC025_ORG_CODE

      AND TEMP_WEB_NOTES.CC025_EXT_ACCT_CODE = web_note_1.CC025_EXT_ACCT_CODE

      AND TEMP_WEB_NOTES.CC025_NOTE_CLASS = web_note_1.CC025_NOTE_CLASS

      AND TEMP_WEB_NOTES.CC025_PROD_CODE = web_note_1.CC025_PROD_CODE

    WHERE  TEMP_WEB_NOTES.CC025_ORG_CODE IS NULL

    GROUP BY web_note_1.CC025_ORG_CODE,

      web_note_1.CC025_EXT_ACCT_CODE,

      web_note_1.CC025_NOTE_CLASS,

      web_note_1.CC025_PROD_CODE

    HAVING  COUNT(*) > 1

    Do you have...

  • RE: Pivot table for Microsoft SQL Server

    Yes, SQL injection could possible be an issue here, if the data in ColumnText is written such way.

    But since the beginning of the UPDATE-statement is hardwired with "UPDATE", I right now can't see...

  • RE: Pivot table for Microsoft SQL Server

    Thanks Ryan.

    I have tried to keep the dynamic SQL executions to a minimum for obvious speed reasons. What I think I have provided is a base for creating crosstabs/pivots for...

  • RE: Pivot table for Microsoft SQL Server

    Yes, in my very first early version. Then I realized that I could potentially come across the 8000 character limit for varchars.

  • RE: After delete Trigger on Transaction

    Change

      UPDATE accountBalance

                SET balance = balance - (SELECT debit-credit FROM DELETED)

        WHERE code = (SELECT account FROM DELETED)

    to

    UPDATE accountBalance 

    SET    accountBalance.balance = accountBalance.balance...

  • RE: Group By with no aggregate: Why???

    Jeff, any idea why DISTINCT behaved significantly different in times using either clustered/non-clustered index and why GROUP BY didn't change times much?

    My gut tells my that a clustered index should...

  • RE: Group By with no aggregate: Why???

    You're welcome, Jeff. Too bad I don't have my old computer with me that had SQL2KSP3 installed to compare times with. 

  • RE: Group By with no aggregate: Why???

    Great script code for testing!

    Is there a difference when having index on the table? Clustered/non-clustered? With/without NOLOCK hint?

    Running your test-script without any modification, I got following times (50 executions)

         2.910-2.976 seconds...

Viewing 15 posts - 2,101 through 2,115 (of 2,169 total)