Forum Replies Created

Viewing 15 posts - 76 through 90 (of 413 total)

  • RE: inserting decimal point

    This might be slightly simpler:

    UPDATE tablename SET field = stuff(field, 4, 0, '.') where LEN(field) > 3

  • RE: Removing TABS & NEWLINE from text field

    When you say "text field", do you mean a field of datatype varchar? Then use something like this:

    select replace(replace(colname, char(9), ''), char(13) + char(10), '')

    from table

    If you mean a field...

  • RE: inserting decimal point

    Or

    select some_value, left(some_value, 3) + '.' + substring(some_value + '00', 4, 2) from @table

  • RE: inserting decimal point

    Using Mathew's table definition (and only because I like to be different ):

    select some_value, substring(stuff(some_value + '00', 4, 0, '.'), 1, 6) from @table

  • RE: Removing NULL rows from table x with # of columns x

    Or try this:

    declare @tablename varchar(100)

    select @tablename = 'yourtable'

    declare @sql varchar(8000)

    select @sql = 'delete ' + @tablename + ' where '

    select @sql =

  • RE: Help modifying SUM

    What's the point in calculating

    SUM(All PDC where EnteredDate in current month) + SUM(All PDC where EnteredDate not in current month)

    Isn't that simply SUM(All PDC)?

  • RE: Alternate Receipts

    Never mind, I guess you still need help Try this query:

    select

      Ind_id as [Individual ID],

      firstname as [First Name],

      lastname as [Last Name],

     ...

  • RE: Need syntax help please

    Exactly - something like

    SELECT H1.PhoneNum, H1.NewCol

    FROM History H1

    INNER JOIN History H2 on H1.ProjectID  = H2.ProjectID and H1.PhoneNum = H2.PhoneNum

    WHERE H1.ProjectID IN (945, 1172)

    AND H1.CallDateTime > getdate() -7 AND H1.AttResult...

  • RE: Trigger causes Deadlock

    Not that I know much about deadlocks. But I have two suggestions for work arounds.

    1. After Connection1 has updated Table2, commit and then update Table1 in a separate transaction.

    2. Let...

  • RE: update with a case statement

    Alternative:

    UPDATE t

    set t.Name = u.name

    from test_update t

    inner join

    (

      select 1 as Id, 'aaa' as Name union all

      select 2, 'bbb' union all

      select 3, 'ccc'

    )

    u on t.Id = u.Id

  • RE: Alternate Receipts

    Using Ray's table definition, try this:

    select distinct A.*

    from #Contribution A

    left join #Contribution B

    on A.Contributorid = B.Contributorid

    and datediff(mm, '1900', B.ContributionDate) = datediff(mm, '1900', A.ContributionDate) + 1

    where B.ContributorId is null

  • RE: How to find missing entries

    I guess the above is faster if you add an index on #AllNumbers:

    ALTER TABLE #AllNumbers

            ADD CONSTRAINT Index_Numbers PRIMARY KEY CLUSTERED(SequenceNumber)

  • RE: Need syntax help please

    Sergiy, I have changed your query a little

    SELECT H1.PhoneNum

    FROM History H1

    INNER JOIN History H2 on H1.ProjectID  = H2.ProjectID and H1.PhoneNum = H2.PhoneNum

    WHERE H1.ProjectID IN...

  • RE: Change a X orientd results set to X oriented.

    You could redesign the answers table such that the columns are as follows:

    Id int, user_id int, answer_id int, answer varchar(100)

    Sample data would be as follows:

    1, 1, 1, 'User 1's answer...

Viewing 15 posts - 76 through 90 (of 413 total)