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.
| Author |
Topic |
|
davemino
Starting Member
1 Post |
Posted - 2008-05-08 : 11:47:09
|
| I am trying to make a field that has info from othe fieldsTable = Page0Fields = LName, FName, SSI want a new field (Folder) to be all three fields.. for exampleLName= SmithFName= JohnSS= 1234I want to update Folder = Smith_John_1234 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 11:51:50
|
| Update Page0SET Folder = ISNULL(LName+'_','')+ ISNULL(FName + '_','') + ISNULL(CAST(SS AS varchar(5)),'') |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2008-05-08 : 11:53:52
|
Or one of these 2?...-- Structure and Datacreate table Page0 (LName varchar(10), FName varchar(10), SS varchar(10))insert Page0 select 'Smith', 'John', '1234'-- Example using selectselect *, LName + '_' + FName + '_' + SS as Folder from Page0-- Example computed columnalter table Page0 add Folder as LName + '_' + FName + '_' + SSselect * from Page0 Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 12:00:13
|
quote: Originally posted by RyanRandall Or one of these 2?...-- Structure and Datacreate table Page0 (LName varchar(10), FName varchar(10), SS varchar(10))insert Page0 select 'Smith', 'John', '1234'-- Example using selectselect *, LName + '_' + FName + '_' + SS as Folder from Page0-- Example computed columnalter table Page0 add Folder as LName + '_' + FName + '_' + SSselect * from Page0 Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part.
I think we need to check for NULL values in all of fields as it might cause result to be returned as NULL. |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2008-05-08 : 12:07:01
|
How do you know returning NULL isn't the requirement? I considered adding that detail, but figured we needed to pin down what was meant a bit first...Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 12:22:03
|
quote: Originally posted by RyanRandall How do you know returning NULL isn't the requirement? I considered adding that detail, but figured we needed to pin down what was meant a bit first...Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part.
Ok . Just thought of specifying it just in case OP preffered non null values |
 |
|
|
|
|
|
|
|