Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate a column with data from 2 columns

Status
Not open for further replies.

gradinumcp

IS-IT--Management
Apr 6, 2005
85
US
Hi there!

I have 2 columns:

1) Division--with numbers 100, 101, 102,....

2) Stations-with numbers 1,2,3,...

I want to create another column say "Div-Station" with values 100-1, 100-2, 100-3, 101-1, 101-2.....so on.

How do i do that in SQL server. I am an absolute beginner in this.

Thanks!

 
UPDATE <tablename> SET <destination columnname> = CONCAT (<first source columnname>, '-', <second source columnname>)

is one way. There are likely others.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
If this table will have rows added to it regularly, creating this additional column is probably contraindicated, as you will have to run this update after every insert.

You could just derive the column during your select statements.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top