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 |
|
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2007-11-19 : 06:36:43
|
| Hi,I have 2 tables and I want to insert from one table (accounts_temp) into the other table (accounts).However, i want to check that the value that i am trying to insert into Accounts doesn't already exist in the table under the column called AccountsGroup.How can I write such a query?Thanks for the helpWhisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-11-19 : 06:41:20
|
| [code]Insert into t1(col1, col2,...)select col1, col2,... from t2 left join t1 on t2.AccountsGroup = t1.AccountsGroupWhere t1.AccountsGroup IS NULL[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2007-11-19 : 08:33:31
|
| Thanks that seems to work :-)Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much. |
 |
|
|
|
|
|