August 12, 2008 at 1:48 pm
Hi,
I have three columns a, b ,c (all strings)
i want to set default value of c as a + '-' + b
is it possible without insert & update triggers??
August 12, 2008 at 2:03 pm
Will you be updating or directly inserting into c? If not use a calculated column.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 12, 2008 at 2:06 pm
i wont be directly inserting/updating c,
i will just insert/update a & b only.........
so i want the effect of insert/update in a & b automatically be appeared in c....
How can i use calculated column??
August 12, 2008 at 2:16 pm
Sorry the real term is computed column. Here is a link about them: http://www.sqlservercentral.com/articles/T-SQL/61764/
Here is some code that demonstrates how they work:
[font="Courier New"]CREATE TABLE #temp
(
first_name VARCHAR(10),
last_name VARCHAR(20),
full_name AS first_name + ' ' + last_name
)
INSERT INTO #temp
SELECT
'Jack',
'Corbett'
SELECT * FROM #temp
UPDATE #temp
SET last_name = 'Corbette'
SELECT * FROM #temp
DROP TABLE #temp
[/font]
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply