lundi 24 août 2015

How do I remove a quote(") from SQL string before or after inputting it into a column?

I have split a name value in one column to get the first and last name to supply in another column. Sometimes I get a quote(") in the front of or beginning of someones name. How do I remove that quote?

I've tried pragmatically but it kicks back error at the set commands for @fname and @lname.

  DECLARE @fname VARCHAR(100)
  DECLARE @lname VARCHAR(100)
  DECLARE @recnum as INT
  DECLARE @i as int
  SELECT @recnum = count(*) FROM dbo.medcor_weeklywire
  SET @i = 1
  WHILE @i <=@recnum
  BEGIN

  SELECT @fname = LTRIM(jw_employee_fname) where [sysid] = @i
  SELECT @lname = LTRIM(jw_employee_lname) where [sysid] = @i
  SET @fname = SELECT REPLACE(@fname,'"','')
  SET @lname = SELECT REPLACE(@lname,'"','')
  update [medcor_weeklywire]
  SET [jw_employee_fname] = @fname, [jw_employee_lname] = @lname

  END

Aucun commentaire:

Enregistrer un commentaire