Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How would you turn this around? 1

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
How would you turn this syntax around to grab the last name from the field vname(name) and populate the last name field(VLNAME)?


UPDATE L3_MASTER_SAMPLE
SET VFNAME =
(
SELECT
SUBSTR(BACKUP.VNAME,1,INSTR(BACKUP.VNAME,' ',-1))
FROM
L3_MASTER_SAMPLE,
BACKUP
WHERE
L3_MASTER_SAMPLE.ID = BACKUP.ID

)
 
Since Instr is not a SQL Server function you have to use Charindex instead.

UPDATE L3_MASTER_SAMPLE
SET VLNAME =
(
SELECT
RIGHT(BACKUP.VNAME,CHARINDEX(' ',BACKUP.VNAME,0))
FROM
L3_MASTER_SAMPLE,
BACKUP
WHERE
L3_MASTER_SAMPLE.ID = BACKUP.ID

)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top