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 2000 Forums
 SQL Server Development (2000)
 Copy values from Col1 to Col2 in t-sql stored proc

Author  Topic 

SQLIsTheDevil
Posting Yak Master

177 Posts

Posted - 2009-03-17 : 12:18:06
Hello,

I made a stored procedure for a purpose unrelated to the problem at hand. Now, in this stored procedure, I created a table variable. In this table variable, I need to copy all the values in one column into another column.

How may I go about doing that?

Thank you.

mfemenel
Professor Frink

1421 Posts

Posted - 2009-03-17 : 13:10:08
Table variables would behave the same as any other table for this task.

declare @mytablea table(cola varchar(20),colb varchar(20))

insert into @mytablea(cola) select 'testing'

update @mytablea set colb=cola
select colb from @mytablea

Mike
"oh, that monkey is going to pay"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-17 : 13:29:55
quote:
Originally posted by SQLIsTheDevil

Hello,

I made a stored procedure for a purpose unrelated to the problem at hand. Now, in this stored procedure, I created a table variable. In this table variable, I need to copy all the values in one column into another column.

How may I go about doing that?

Thank you.


you mean copying data b/w columns of table variable or from table variable to another table?
Go to Top of Page

SQLIsTheDevil
Posting Yak Master

177 Posts

Posted - 2009-03-17 : 15:08:24
Hi,

Yes, I meant copying columns from a table variable to the same table variable.

The above query worked. I don't know why but I thought it was something more complicated.

Thank you!
Go to Top of Page
   

- Advertisement -