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 |
|
Gina
Starting Member
4 Posts |
Posted - 2012-01-24 : 18:33:04
|
| Hi, Hoping someone can help please:I have two tables, one with thousands of job numbers and the other with 8 accounts I need to assign to each job number, here is sample of the tables:Table 1 Table 2JobNumber Account1023 53402251 53553123 53564258 etc 5357 etcIn a new table I would like each job to look as follows:1023.53401023.53551023.53561023.53572251.53402251.53552251.53562251.5357 etc etc..I am stumped as to how I go about writing this, can anyone help please as I am quite new to this...Thanks,Gina |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-01-24 : 18:44:17
|
| If all you want is for each Job Number to be associated with every possible account, then you need to CROSS JOIN themSelect JobNumber,AccountFrom table1Cross Join table2JimEveryday I learn something that somebody else already knew |
 |
|
|
Gina
Starting Member
4 Posts |
Posted - 2012-01-24 : 19:01:38
|
| You're a GEM!That's too easy, thanks so much, I really appreciate it! |
 |
|
|
Gina
Starting Member
4 Posts |
Posted - 2012-01-24 : 20:37:30
|
| Another question how would I then write this as an update Statement please:Select JobNumber,AccountFrom table1Cross Join table2 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-01-24 : 22:15:10
|
quote: Originally posted by Gina Another question how would I then write this as an update Statement please:Select JobNumber,AccountFrom table1Cross Join table2
what do you want to update ? which table ? which column ? update with what ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Gina
Starting Member
4 Posts |
Posted - 2012-01-24 : 23:42:13
|
| in a new table(table 3) I would like to have the following in a column:New Job Number1023.53401023.53551023.53561023.53572251.53402251.53552251.5356 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-01-25 : 00:52:33
|
[code]insert into table3 (JobNumber, Account)Select JobNumber,AccountFrom table1Cross Join table2[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|