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
 General SQL Server Forums
 New to SQL Server Programming
 updating values

Author  Topic 

sandeep1209
Starting Member

6 Posts

Posted - 2012-03-20 : 02:41:17
Hi frinds,

In my database employee table contains six columns like , Now i suppose to create one duplicate table for employee instead of all columns i taken 3 columns for duplicate columns like below

select * from employee
select eno,ename,job into employee1 from employee
select * from employee1

Now in duplicate table i added commotion column
alter table employee1 add comm int

Now commotion column contains null values
now i want to add commotion values which are having in base table commotion fields

How any one can tell me ?

Thank's
Sandeep.

sandeep

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-20 : 02:45:55
>> now i want to add commotion values which are having in base table commotion fields

What columns in the base table?

Read the hunt link in my sig...

BUT, I'm a big proponent of NOT having Duplicated data, why not just add the column to the base

We need to see sample data and what's suppose to happen as a final result


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-20 : 15:12:46
are you learning update statement by any chance?
Your problem doesnt sound like a practical scenario
if you want comm data also why not include it in select creating table itself

select eno,ename,job,comm into employee1 from employee

if you've already created table you need an update now

update e1
set e1.comm = e.comm
from employee1 e1
join employee e
on e.eno = e1.eno
and e.ename = e1.ename
and e.job = e1.job


i hope eno,ename,job combination is unqiue within employee table

Also as Brett says I didnt get reason why you're replicating data like this in first place
can you elaborate?

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

Go to Top of Page
   

- Advertisement -