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)
 Update record per row

Author  Topic 

tech_1
Posting Yak Master

129 Posts

Posted - 2011-11-08 : 13:01:51
Hi.
need to run a one off quick job to update a field in a table by using the first 10 characters of that rows/record "Title."

how can I do it?

UPDATE Operator
SET InternalShortcode = (SELECT SUBSTRING (Title, 1,10) FROM Operator)

the above obviously doesnt work - because more than 1 result would have been found

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-08 : 13:35:49
UPDATE Operator
SET InternalShortcode = LEFT(Title, 10)


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -