Removing white space from columns names dynamically
Hi Team , I am trying to generate a dynamic query in mysql to remove any space in column name.
In sql server I use something like below.
```
DECLARE @s VARCHAR(500)
DECLARE @tablename VARCHAR(500) ='mytable'
SELECT @s = ISNULL(@s+', ','') + '[' + c.name + ']' + ' as ['+replace(c.name,' ','')+'] '
FROM sys.all_columns c join sys.tables t
ON c.object_id = t.object_id
WHERE t.name = @tablename
SELECT 'select ' + @s + ' from ' + @tablename as Query
```
Subject
Written By
Posted
Removing white space from columns names dynamically
August 09, 2021 02:41PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.