Most of my tables have four fields that include:
Created datetime not null default = GetDate()
CreatedBy varchar(50) not null default = suser_sname()
Updated datetime null
UpdatedBy Varchar(50) null
For data that I display in a grid, I want to combine these fields to show the "Last Edit" in the form of "datetime" by "user".
Knowing that my Created and CreatedBy fields will never be null, Coalesce seems to be the answer but I'm getting errors with the following:
,Convert(varchar(20),Coalesce(i.Updated,i.Created) ,120) + ' by ' + Coalesce(i.UpdatedBy,i.Created) as [LastEdit]