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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A quickie - SELECT INTO

Status
Not open for further replies.

loydall

Programmer
Apr 4, 2001
12
GB
Hello,

Here's a table (TableA):

------------
id | name |
------------
1 | bob |
2 | john|
3 | tom |
4 | tim |

and here's another table (TableB):

---------------------
personId | language |
---------------------
1 | Eng |
2 | Eng |
3 | Eng |
4 | Eng |

How do I use a SELECT INTO (i think that's the correct method) to acheive the data in TableB?

What I mean is, I know how to use a select into to put the ids accross but I also want to set a default value for the language - Eng.

Any ideas?

 
Not quite sure I understand what you mean, but you can try this:

INSERT INTO TableB SELECT id, 'Eng' FROM TableA
 
If you are trying to set a default value you have to do that within the create table command to create the table.

If all you want are values then the code that JarlH posted will do the trick.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top