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 2012 Forums
 Transact-SQL (2012)
 Populate a column based from 2 others columns.

Author  Topic 

yguyon
Starting Member

11 Posts

Posted - 2015-01-27 : 15:23:30
I would like to populate a column of a table based from 2 other column

If Column A is greater then column B then column C should be 1
if column A is less then column B then column c shoulbe be 0

Column A and B are dates field.


I'm trying to figure out how to do this in a store procedure.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-01-27 : 15:39:30
udpate table
set columnc = case when columna > columnb then 1 else 0 end
Go to Top of Page
   

- Advertisement -