Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Insert into existing table but for each group?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

129 Posts

Posted - 01/27/2013 :  18:28:07  Show Profile  Reply with Quote
I have a large table with existing data.
The joining key/column is "UserID" (varchar)
I want to insert a record in this table but for each UserID found in the table

how can I do this?

There are multiple single userID's in there, each with a different column value which is linked to another table (think of it as a joining reference table for settings for each user)

any ideas?

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 01/27/2013 :  18:47:46  Show Profile  Reply with Quote
I did not quite follow what you meant by groups - if the data for a given userid already exists, don't you want to do an update rather than insert duplicate rows for the same userid? Can you post the schema for the two (or more tables) that are involved along with some sample data?
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 01/28/2013 :  00:03:52  Show Profile  Reply with Quote
Sounds like OP wants to replicate some data for each of existing users but add only once per user. Seems like currently table is having multiple records per user.

If thats the case, it should be something like

INSERT INTO YourTable (UserID,.. other columns)

if this was not your question then please post some sample data as James suggested as we cant make out much from your current explanation.

SQL Server MVP

Go to Top of Page

Posting Yak Master

160 Posts

Posted - 01/29/2013 :  08:12:17  Show Profile  Reply with Quote
If I am not wrong, you wanted to lookup for userid's existing on other table in your join condition and for each userid it matched, you wanted to insert values. Let us know in detail.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000