Forum Replies Created

Viewing 15 posts - 286 through 300 (of 541 total)

  • RE: Lookup Table Design

    Where could one get a list of these standard codes?

  • RE: Finding and Deleting Duplicate Data

    Here's the full script:

    if object_ID('tempdb..#Payment') is not null drop table #Payment

    CREATE TABLE #Payment(

     PaymentID int identity Not nUll Primary Key,

     CustomerNumber int  NOT NULL,

     PostedDatetime datetime NOT NULL,

     PaymentAmt money  NOT NULL,

     PaymentMemo varchar(200) NOT NULL,

     CCRefNum char(10) NOT NULL

    )

     

    Insert #Payment Values (1, '01/01/2004', 1, '',...

  • RE: Finding and Deleting Duplicate Data

    This is a pretty good technique, but there are problems with it.  Using derived tables in a query can be very powerful, but they can also cause excessive use of...

  • RE: Avoiding cursors, but...

    true, or you can use something like this (for a csv, say):

    select @var = isnull(@var + ',', '') + value from table.

    If I dealing with a lot of rows or...

  • RE: Avoiding cursors, but...

    Nope...didn't test it.  You're right though, it doesn't work.

    Very odd...

    cl

  • RE: Alter Table

    Although you can have only one PK, you can have multilple columns in your PK.

    ALTER TABLE [dbo].[Table] DROP CONSTRAINT [TablePK]

    GO

    ALTER TABLE [dbo].[Table] ADD CONSTRAINT [TablePK] PRIMARY KEY  CLUSTERED

     (

      [PK1],

      [PK2]

    &nbsp

  • RE: Avoiding cursors, but...

    No need for a derived table or COALESCE function:

    SELECT  DISTINCT @strString1 = @strString1 + sql_name + ', '

    FROM #temp A ORDER BY SQL_name

  • RE: Update a table and display value

    If you absolutely must have a unique stamp for each row, then simply use the uniqueidentifier data type.

    cl

  • RE: better method for a trigger?

    Wow, if your trigger is timing out you've got some serious problems.  I'm a little confused at to what you mean by data view.  What are you using to view...

  • RE: Update a table and display value

    if you're worried about triggers screwing with @@Identity, use the function SCOPE_IDENTITY( ) instead.  Or you can use IDENT_CURRENT('table_name')...

    Lot's of options for attaining the last identity column...it's a nice feature...

  • RE: How do i group by month?

    Actually, there are two functions you can use.  select Month(getdate()), and select datename(mm, getdate()).

    As far as doing a pivot table...in that each month becomes a column...is a lot more complicated. ...

  • RE: correlated subquery in delete statement?

    Here is an elegant way to do this:

    delete  t1

    from  NA_ATTRIBUTE_DATA t1

    JOIN  NA_ATTRIBUTE_DATA t2 on t1.MONBR = t2.MONBR

    where t1.ROWNUM < t2.ROWNUM

    This will delete all records in the table where the MONBR...

  • RE: Update a table and display value

    You can't do this in a function, as you can't issue "Update" commands on any tables (except table variables).

    Also, using the syntax Kenneth proposed (which is good, although using an...

  • RE: Need help implementing FILO ordering on fixed size database

    If there is no primary key violation (which there probably should be in an ideal schema), you can join the table to itself and delete all older records in the...

  • RE: Sound like matching

    There are a bunch of SQL scripts that are better than the soundex functions.  For example, the script at this site:

    http://www.tek-tips.com/gfaqs.cfm/lev2/4/lev3/27/pid/183/fid/4110

    correctly equates "Knight" to "night".

    select dbo._SoundexAplhaFunction ('knight'),

        dbo._SoundexAplhaFunction ('night')

    returns...

Viewing 15 posts - 286 through 300 (of 541 total)