SHARE
TWEET

Untitled

a guest Jun 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UPDATE SET TITLE = TITLE.Split(' ')[0]
  2.      
  3. UPDATE yourTable
  4. SET TITLE = SUBSTRING(TITLE, 1, CHARINDEX(' ', TITLE) - 1)
  5. WHERE CHARINDEX(' ', TITLE) > 0;
  6.      
  7. update t set
  8.   t.Title = a.First_Word
  9. from Your_Table
  10. outer apply (
  11.   select top 1
  12.     value as First_Word
  13.   from t.TITLE.STRING_SPLIT(' ')
  14. ) as a
  15.      
  16. create function Get_FirstWord(@words varchar(max))
  17. returns varchar(max) as
  18. begin
  19.   declare @First_word varchar(max);
  20.  
  21.   select top 1
  22.     @First_word = value
  23.   from @words.string_split(' ');
  24.  
  25.   return @First_word;
  26. end;
  27.      
  28. update Your_Table set
  29.   Title = Get_First_Word(Title)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top