dbTalk Databases Forums  

DtS task to remove quotes

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss DtS task to remove quotes in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
James Johnson
 
Posts: n/a

Default DtS task to remove quotes - 11-15-2004 , 09:04 PM






I have a script to remove double quotes in my table,
however, when it gets to the identity column it errors
out. How can I overcome or skip over the identity column
using this script?



/*================================================= ==
BEGINNING OF SCRIPT
================================================== =*/

declare @col varchar(50)
declare @update varchar(200)

declare cur cursor for
select column_name
from information_schema.columns
where table_name = 'mytable'

open cur

fetch next from cur into @col

while @@fetch_status =0
begin
print @col
set @update = 'update std_sess_internet set ' + @col +' =
replace(' +@col+','+char(39)+'"'+char(39)+','+char(39)
+char
(39)+')'
exec (@update)
fetch next from cur into @col
end
close cur
deallocate cur

select * from std_sess_internet -- Displays the
updated values

/*================================================= ==
END OF SCRIPT
================================================== =*/

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: DtS task to remove quotes - 11-16-2004 , 01:45 AM






In message <5d4701c4cb88$f8e933c0$a401280a (AT) phx (DOT) gbl>, James Johnson
<anonymous (AT) discussions (DOT) microsoft.com> writes
Quote:
I have a script to remove double quotes in my table,
however, when it gets to the identity column it errors
out. How can I overcome or skip over the identity column
using this script?

Put a where clause in the information_schema.columns select statement
and check the DATA_TYPE column to include character type columns only.

You cannot use a function such as replace on an integer column, because
replace expects a string as the first input, and of course being an
integer it can never hold a quote anyway so trying to do so will not
only raise an error, but also is not relevant.

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.