www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Using replace function

  1. #1
    Join Date
    Jun 2008
    Posts
    33

    resolved [RESOLVED] Using replace function

    I am using sql server 2005 and this is my problem:

    i have a variable defined as nVarchar
    e.g. @name = nVarchar (1000)

    single quotes can be inserted into that variable as values

    e.g. sandra's world

    is there a way to use a replace function so when i select that variable i can replace that single quote with space?

    e.g.
    declare @name nVARCHAR(1000)
    set @name ='sandra''s world'
    right now when i select @name it pulls as : sandra's world
    how do i select @name so it pulls as : sandra s world

    your help is highly appreciated.

    Thanks.

  2. #2
    Join Date
    Jun 2008
    Posts
    33
    Nevermind ... i found it in diff website.
    Thank you .. here is the solution.

    declare @name nVARCHAR(1000)
    DECLARE @SQL_Select nVARCHAR(max)
    set @name='hello'''s'

    set @SQL_Select = @name

    print @sql_select
    SET @sql_select = REPLACE(@sql_select, '''',' ')
    print @sql_select

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles