Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
Hello Friends,
 
am working on SqlServer 2005. I have two tables in my Database.
 
Table 1 is history
Table 2 is UserDetails
 
I have a table name with History, In this i have a coulmn name 'TimeStamp' Now I need to copy all these data to userDetails table.
 
How to copy only a particular column to another table in sqlserver 2005.. Help me.
 
thanks in advance.
Posted 6-Nov-12 0:50am
Comments
zaid Qureshi at 6-Nov-12 6:36am
   
jst try with copy n paste
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This may help you
Insert into UserDetails(TimeStamp)
select TimeStamp from History
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

if you are copying all the record, and inserting them as new then
 
Insert into UserDetails(TimeStamp)
select TimeStamp from History
 

but if you are copying from history table and inserting them to existing column then
 
update userDetails set TimeStamp= (select TimeStamp from history where history.userID= UserDetails.UserID)
--modify the condition to your needs,
 
this will not insert records as new, but will only update the existing records.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 250
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 DamithSL 125
4 Afzaal Ahmad Zeeshan 120
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100