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 |
|
gudushen
Starting Member
16 Posts |
Posted - 2008-10-27 : 08:47:42
|
| Hi, I'm trying to update columns of one table using another table, problem is the columns are not ordered the same and sometimes does not have the exact same name. Also, one table is larger than the other. Is there a way to update this without having to type out every column I need(there's way to many)? |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-10-27 : 09:05:06
|
| The answer to your question is no, you have to use the column names. However this can be substantially simplified if you have many columns by using the informations_schema.columns system view. It will help you get the column names in any given table in your database. Try this query and you'll see what I mean (you have to do some cutting and pasting but at least you don't have to type everything out):SELECT * FROM information_schema.columns WHERE table_name = 'mytablename'ORDER BY ordinal_position- Lumbago |
 |
|
|
gudushen
Starting Member
16 Posts |
Posted - 2008-10-27 : 09:12:00
|
quote: Originally posted by Lumbago The answer to your question is no, you have to use the column names. However this can be substantially simplified if you have many columns by using the informations_schema.columns system view. It will help you get the column names in any given table in your database. Try this query and you'll see what I mean (you have to do some cutting and pasting but at least you don't have to type everything out):SELECT * FROM information_schema.columns WHERE table_name = 'mytablename'ORDER BY ordinal_position- Lumbago
Thank you, this would definitely help.gudushen |
 |
|
|
|
|
|