Reputation:
How can I possible trim a white space before my column. I have a column called Cost and I have given a white space before.
[ Cost] [int] NULL,
I am using these queries and doesn't work. Can anyone correct me.
SELECT REPLACE(Cost, ' ', '')
select REPLACE (' Cost', ' ', '' )
Upvotes: 0
Views: 316
Reputation: 7017
I guess you should change table definition so that column name does not have white space in it. You can do that with sp_RENAME
procedure.
EXEC sp_RENAME 'TableName.[ Cost]' , 'Cost', 'COLUMN'
If you can't do that, you can refer column using square braces:
SELECT [ Cost]
FROM TableName
Upvotes: 4