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
 General SQL Server Forums
 New to SQL Server Programming
 create columns of existing column

Author  Topic 

dosteroid
Starting Member

29 Posts

Posted - 2011-08-30 : 05:48:47
Hi

I have a table TabA with a Column ColA where ColA contains the following values 540000,550000,541000,551000 and 541100,551100 (and so on). How do I modify the table, so instead of one column I get 3 columns out of the existing Column ColA, where Col1 = 540000 and 550000, Col2 = 541000 and 551000 and Col3 = 541100 and 551100?

this is just a small example of the actual table which is much much larger...

Help appreciated




DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2011-08-30 : 06:39:12
so you want to break up a single column that holds a comma separated value into multiple columns that hold a numeric value, the word "and", then another numeric value?

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-30 : 08:18:51
see scenario 4

http://visakhm.blogspot.com/2010/01/multipurpose-apply-operator.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

dosteroid
Starting Member

29 Posts

Posted - 2011-08-30 : 08:41:44
Cheers
Go to Top of Page

gwilson67
Starting Member

42 Posts

Posted - 2011-08-30 : 09:57:59
You may want to look into derived columns. It supports creating a formula.

Greg
http://www.freewebstore.org/tsqlcoderepository
Powerful tool for SQL Server development
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-30 : 10:00:18
sorry how would derived column come handy here?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -