Re: Inserting a string with an Apostrophe

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 04/30/04


Date: Fri, 30 Apr 2004 07:09:35 +0530


  hi cb,

  When you assign the value to the variable using select statement, it
automatically picks up the single quote as it is. See following example.

  --sample data
  drop table t
  create table t(name varchar(50))

  insert into t values('Mc''donald')

  --lets perform steps you've mentioned.
  --1. read in a record from the SourceTable
  --2. assign the variables

  declare @x varchar(50)
  select @x = name from t

  --3. write the data into the DestinationTable using the assigned variables
  -- insert the data into same table.

  insert into t values (@x)

  --check the data, you will see 2 rows with same values
  select * from t

  --
  Vishal Parkar
  vgparkar@yahoo.co.in