sql中:
update article000 set prices = (select left(copyfrom,charindex('|',copyfrom)-1)
from article where article.articleid = article000.articleid)
where exists( select articleid from article where article.articleid = article000.articleid)
mssql2000 中使用 substring 和 charindex 函数截取在某个字符之前的串
为了得到字符串中某个字符串之前的子串,可以使用 charindex 和 substring 配合来得到
USE pubs
SELECT SUBSTRING(notes, 0, CHARINDEX('o', notes)) subString,
DATALENGTH (SUBSTRING(notes, 0, CHARINDEX('o', notes))) Length,
CHARINDEX('o', notes) charIndex,
notes
FROM titles