Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Set a flag for a column?

Author  Topic 

Blastrix
Posting Yak Master

208 Posts

Posted - 2001-12-18 : 12:11:39
I have a table which contains some project information. In that table it has a field for the UserId which created the project record, some other irrelevant fields and a LastUpdatedByUserId field, which contains exactly what it says(the last person to update the project record). How could I perform a select/view to get all records which would allow me to return a record for the user who created the record, and then another record with the userId being that of the updatedUserId, with a flag set saying PerformedUpdate? Is it even possible?

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2001-12-18 : 12:30:36
Like this?

SELECT ProjectRecordId, CreateUserId AS UserId, CONVERT(bit, 0) AS PerformedUpdate
FROM ProjectInformation
UNION ALL
SELECT ProjectRecordId, LastUpdatedByUserId, 1
FROM ProjectInformation



Go to Top of Page

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2001-12-18 : 12:39:40


SELECT
entries.IDENTITYCOL ID,
CASE modes.mode
WHEN 1 THEN created.Name
ELSE updated.Name
END UserName,
modes.mode
FROM
CatalogItems entries
INNER JOIN
Users created ON entries.CreatorID = created.UserID)
INNER JOIN
Users updated ON entries.UpdatorID = updated.UserID)
CROSS JOIN
(SELECT 0 mode UNION SELECT 1 mode) modes
ORDER BY
entries.IDENTITYCOL,
modes.mode


- Onamuji
Go to Top of Page
   

- Advertisement -