469,943 Members | 2,438 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,943 developers. It's quick & easy.

Default value being a concatenation of other columns

Hello all,

Does anybody know if it is possible to set the default value of a
field to equal the concatenation of 2 other fields?
I.E.
Field 1 = 123
Field 2 = 345
Field 3 = (Field1 + Field2) = 123345

This is easy enough to do using a stored procedure, but I'm trying to
use the import tool and so need to do the concatenation by default.

Many thanks,
Drew.

Jul 19 '07 #1
1 5347
Drew (an******@gmail.com) writes:
Hello all,

Does anybody know if it is possible to set the default value of a
field to equal the concatenation of 2 other fields?
I.E.
Field 1 = 123
Field 2 = 345
Field 3 = (Field1 + Field2) = 123345

This is easy enough to do using a stored procedure, but I'm trying to
use the import tool and so need to do the concatenation by default.
No, but you can define a computed column:

CREATE TABLE nisse (kalle int NOT NULL,
lisa int NOT NULL,
putte AS kalle + lisa)

Of course, if you need to update the columns independently of each
other, this is not any feasible solution.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jul 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by | last post: by
1 post views Thread by tg.foobar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.