The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> MS SQL Development
|
Column logic
Discuss Column logic in the MS SQL Development forum on Dev Shed. Column logic MS SQL Development forum discussing administration, MS SQL queries, and other MS SQL-related topics. SQL Server is Microsoft's enterprise database engine.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 29th, 2012, 09:51 AM
|
|
Contributing User
|
|
Join Date: Oct 2006
Posts: 142
Time spent in forums: 11 h 32 m 7 sec
Reputation Power: 7
|
|
|
Column logic
Hi, is there a way to make simple logic for columns in a table? For example, if a value in 2 columns are equal, then set a third column to TRUE.
Thanks
__________________
Cheers,
Fred Liu
|

May 29th, 2012, 10:00 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
|
yes, but you would want to do this only in a SELECT query, not in the table itself as an actual column
|

May 29th, 2012, 12:46 PM
|
|
Contributing User
|
|
Join Date: Oct 2006
Posts: 142
Time spent in forums: 11 h 32 m 7 sec
Reputation Power: 7
|
|
Quote: | Originally Posted by r937 yes, but you would want to do this only in a SELECT query, not in the table itself as an actual column | Why is it not a good idea for the actual table to automatically change the 3rd column once the previous 2 columns are equal? I don't want to have to run a SELECT statement each time the table is updated.
|

May 29th, 2012, 02:35 PM
|
 |
Contributing User
|
|
|
|
|
Seems like it would be another field to keep track of. Just worry about it at "run time".
That is the point r937 is trying to get across.
|

May 29th, 2012, 08:31 PM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
Quote: | Originally Posted by fred2028 I don't want to have to run a SELECT statement each time the table is updated. | i agree completely, and you're in luck, you don't have to
just do your updates as normal, and of course don't update this mythical third column because it won't even be there
when you want to see the data, that's the only time you do the SELECT, and that includes the calculation

Last edited by r937 : May 29th, 2012 at 08:37 PM.
|

May 30th, 2012, 09:58 AM
|
|
Contributing User
|
|
Join Date: Oct 2006
Posts: 142
Time spent in forums: 11 h 32 m 7 sec
Reputation Power: 7
|
|
Quote: | Originally Posted by r937 i agree completely, and you're in luck, you don't have to
just do your updates as normal, and of course don't update this mythical third column because it won't even be there
when you want to see the data, that's the only time you do the SELECT, and that includes the calculation
 | OK thanks!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|