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)
 Question about UPDATE a table

Author  Topic 

kusanagirong
Starting Member

4 Posts

Posted - 2010-06-27 : 23:55:44
Hello,
I got a question about updating a table:

The table has a column contains 50 characters. Now I already got data in the table, the data are strings have length from 6 to 25. But now I found I only need the first 6 characters in the column. How can I update the existing table column to get rid of redundant characters?

Thanks advance!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-06-28 : 00:00:19
[code]
update t
set somecol = left(somecol, 6)
from yourtable t
[/code]


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

Go to Top of Page

kusanagirong
Starting Member

4 Posts

Posted - 2010-06-28 : 00:05:35
Thank you~~~
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-06-28 : 00:11:08
Welcome


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

Go to Top of Page
   

- Advertisement -