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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 for every value in a table..

Author  Topic 

laptop545
Starting Member

11 Posts

Posted - 2010-03-19 : 12:45:02
Hello All,

i am writing a db script and i have problem in between it.

I have a temp table ( created from output from another SP), with values say:


ID
1234
1235
1236
1237

Now i want this following query for every value in the above table :

Insert into P_PEOPLE (id,name,user) values ((every value in the above table), .........)

how should i do this, because some times, the above table may consist many rows like say 100.

smmcroberts
Starting Member

3 Posts

Posted - 2010-03-19 : 12:50:06
Where are you getting the name and user?
You can insert the ID by using an insert/select:

Insert into P_PEOPLE (id,name,user)
select id, ~name-source~, ~user-source~ from temp-table

But that leaves an open question on the name and user values.



--Steve
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-19 : 12:55:26
Insert into P_PEOPLE (id,name,user)
SELECT id,name,user FROM #yourTemptable

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-19 : 12:56:13
OOps..I didnt refresh

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -