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 2008 Forums
 Transact-SQL (2008)
 need help on SQL

Author  Topic 

Idyana
Yak Posting Veteran

96 Posts

Posted - 2011-12-31 : 02:13:18
I've table and data as following,
declare @t1 table
(col1 varchar(30), col2 varchar(30))

insert into @t1 values('my CAT looks sick','');
insert into @t1 values('LION my favourite animal','');
insert into @t1 values('please protect your cat','');
insert into @t1 values('dont hurt your horse','');


I need to move CAT word into col2 but I dont know how to do that

My expected result will be
@t1
col1 | col2
-------------------------------------
my CAT looks sick | CAT
LION my favourite animal |
please protect your cat | cat
dont hurt your horse |


need help

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-31 : 02:15:36
only CAT ?


update @t1
set col2 = 'CAT'
where col1 like '%CAT%'



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Idyana
Yak Posting Veteran

96 Posts

Posted - 2011-12-31 : 02:38:07
how about cat, dog and lion?
Go to Top of Page
   

- Advertisement -