Viewing 15 posts - 76 through 90 (of 136 total)
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...
June 2, 2005 at 10:05 pm
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...
June 2, 2005 at 9:33 pm
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...
May 23, 2005 at 6:48 pm
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.
May 22, 2005 at 11:51 pm
3. EXEC ('SELECT ' + @tablename + ' , E.EMPLOYEEID FROM ' + @tablename + ' E ')
This will fail because it translates to:
SELECT tblEmployees , E.EMPLOYEEID FROM tblEmployees E...
May 22, 2005 at 11:49 pm
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...
May 22, 2005 at 11:32 pm
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...
May 22, 2005 at 11:25 pm
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...
May 22, 2005 at 11:13 pm
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...
May 20, 2005 at 3:48 am
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...
May 19, 2005 at 9:13 pm
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...
May 19, 2005 at 12:40 am
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...
May 18, 2005 at 9:14 pm
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...
May 18, 2005 at 7:49 pm
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.
May 17, 2005 at 12:26 am
Viewing 15 posts - 76 through 90 (of 136 total)