sql-server


Update table column for removing unwanted double quotes in SQL Server


I want to update table entries simultaneously for all columns in one go.
Suppose in the table, there is one column EmployeeName with entries like "SAM", "Jhon" and so on...
I need all this entries under its column should appear like SAM, Jhon only... Double quotes should not be there, please provide me query for the scenario.
Thanks in advance
Use Replace Function as next:-
update TableName
set columnName= REPLACE(columnName,'"','')
Demo:-
Create table #Dummy (col varchar(100))
insert into #Dummy values ('"SAM", "Jhon", "Smith"')
update #Dummy
set col = REPLACE(col,'"','')
select * from #Dummy
Result:-
SAM, Jhon, Smith
update table1 set column1 = case
when column1 = 'entity1' then 'entity2'
when column1 like '%entity3%' then 'entity4'
else 'entity5'
end
To remove left-most quote:
UPDATE MyTable
SET EmployeeName = SUBSTRING(EmployeeName, 2, LEN(EmployeeName))
WHERE LEFT(EmployeeName, 1) = '"'
To remove right-most quote:
UPDATE MyTable
SET EmployeeName = SUBSTRING(EmployeeName, 1, LEN(EmployeeName)-1)
WHERE RIGHT(EmployeeName, 1) = '"'
You can also use a simpler way to remove all the quotes.
update MyTable set EmployeeName = replace(EmployeeName,'"','')
Why not try the Replace function.
Syntax: REPLACE ( string_expression , string_pattern , string_replacement )
If your table consist the data with double quote in the column, you need to update the table with the following query;
Update <tablename>
Set <columnName> = REPLACE(<columnName>,'"','')
where <ColumnWithUniqueVale> = <something>
e.g Replace(EmployeeName,'"','')

Related Links

MDX SSAS 2008 Last year calculation - Leap year issue
saving a VB timespan value in SQL database
test if an action it was an update in triggers
sql server clustered index on non unique keys
How to use MSSQL DSN as URL in DataSource.groovy
Value cannot be null, Parameter name: viewInfo
How to make recipient address dynamic ,so i can avoid making changes in SSIS package?
SQL Server 2005 - Check/Validate null values and add to results
Parse XML data in SQL Server 2012
Primary Key on existing data
Can't get SQL Server to start or connect to my local database engine through SSMS
Retrieve a uniform data sample from a table
Reading multiple records related to every record in the result set at a time
Schema Changes to Integrate Facebook and Google Login
file stream vs local save in sql server?
Pivot or transpose a table in SQL Server without GROUPING BY

Categories

HOME
numpy
erlang
tinyos
oauth
voip
boost-thread
angular2-routing
puppet
wms
ruby-on-rails-3
azureservicebus
ll
snap.svg
tizen-wearable-sdk
simpy
actionscript-2
gimp
powershell-v3.0
oclint
cartodb
hashicorp-vault
dryioc
tee
opera-mini
reduction
android-toolbar
ada
ios10.3
ip-camera
plupload
multiple-columns
google-maps-android-api-2
apply
opencart2.3
jenkins-job-dsl
branch
metadata-extractor
i3
system.data.sqlite
superagent
bxslider
red-black-tree
pari
picturebox
outsystems
skygear
text-files
wfp
elfinder
initializer
intersystems-ensemble
pytest-django
resuming-training
timesten
recycle-bin
slot
typhoon
cleditor
easing
excon
unsatisfiedlinkerror
asteriskami
spatial-query
gmsmapview
spinlock
fill
brackets-shell
enyo
lmfit
registrykey
fabric-twitter
futuretask
integral
xjc
type-mismatch
xaml-designer
magento-1.12
ejabberd-saas
django-1.6
docopt
surrogate-key
bullet
io.js
late-static-binding
map-force
android-json-rpc
bfd
document-database
bigint
modeshape
driver-signing
sql-server-2012-web
vmware-server
qt4.6
xml-libxml
vt100
sequelpro
vim-powerline
datarepeater
tfs-power-tools
mpmovieplayer
hadoop-plugins
scala-2.8
mvvm-foundation
act
dotproject

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App