Forum Replies Created

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

  • RE: How to Ensure Only 1 Bit Valued As 1 in Table

    I would use a trigger, which sets all any original '1's to '0'. That way, you only have to worry about setting the new one to 1, and the old...

  • RE: Help with Loop or cursor

    No, you don't need a cursor.

    I would start by listing the ids, and their earliest instance.

    select t.id, min(t.time)

    from tbl t

    group by t.id

    Then you can work out what the first time...

  • RE: picking the "best" row out of a set

    Sorry - it was just a typo, putting 'desc' instead of 'asc'.

    If you can describe what your actual problem is, it should be fairly easy to get a solution using...

  • RE: what is wrong in query??

    Of course... when I refer to 'tblEmployees' above, you would have EMPLOYEES. I just want to make it clear that it's a table name.

  • RE: what is wrong in query??

    3. EXEC ('SELECT ' + @tablename + ' , E.EMPLOYEEID FROM ' + @tablename + ' E ')

    This will fail because it translates to:

    SELECT tblEmployees , E.EMPLOYEEID FROM tblEmployees E...

  • RE: Corrleated Subquery problem...

    I think it's a really bad way of doing it, because it doesn't seem right to return the data that way. Much better to return two sets of data, which...

  • RE: picking the "best" row out of a set

    Worth noting that you can get a list of everyone's best rows with:

    select * from #tbl t

    where t.i =

    (

    select top 1 t1.i FROM #tbl t1

    where t1.pid = t.pid

    order by...

  • RE: Recursive Cursors

    You shouldn't use a cursor for this, you should just use a query.

    If you give a few more details, then it should be easier to get some code sorted for...

  • RE: Select any 5 rows in random

    Yes, sorry. I was writing it the Oracle way, where you can use rownum like that. I haven't played with SQL2005 enough yet to work out some of the tricks...

  • RE: Select any 5 rows in random

    Yup. That's right. If you have a few million rows, then this isn't a good way of doing it.

    In SQL2005 with RowNumber, you'll be able to pick some random numbers...

  • RE: SQL Servers

    Nope. You can list the servers which are 'linked', using sp_linkedservers, but listing all the SQL Servers on a network isn't something that T-SQL is designed for.

    Sorry. You'll have to...

  • RE: Breaking one date-range into several, based on overlaps with other dates?

    Tom,

    I think I mis-read your question anyway... you're not really looking for overlaps - in fact, the hospital records won't overlap. You're looking for the gaps.

    Try this (uncomment the lines...

  • RE: Breaking one date-range into several, based on overlaps with other dates?

    Finding overlaps is just a matter of looking for two date ranges where both start dates are earlier than both end dates.

    So you can easily join a table with itself...

  • RE: referential integrity in ms-access

    MS-Access? You just set up 'Relationships'. Perhaps you'd get better answers in an MS-Access forum.

    Good luck for running a website on an MS-Access database. Not something I'd ever do.

  • RE: GROUP BY problem

    No problem.

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