Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to avoid single quote when exporting to excel

Author  Topic 

saini_balvinder
Starting Member

22 Posts

Posted - 2008-01-22 : 22:59:36
Hello,

is there some way to avoid single quote for all fields (including text) in excel when we export data from sql server? i dont want to have any single quote in excel when i export data.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2008-01-23 : 00:14:19
Replace(fieldName, Char(39), '')
Go to Top of Page

saini_balvinder
Starting Member

22 Posts

Posted - 2008-01-23 : 00:50:35
where to use this function? in select clause before data generation or after that?
Go to Top of Page

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-01-23 : 00:55:52
In select clause where you are getting result like
Select Replace(QuoteFiels, Char(39), '') as [WithoutQuote] from yourtable

example:
declare @Table4 table
(
nam varchar(30)
)

Insert into @Table4 values('sunil''s')
Select Replace(nam, Char(39), '') as [WithoutQuote] from @Table4
Go to Top of Page

saini_balvinder
Starting Member

22 Posts

Posted - 2008-01-23 : 01:09:07
thanks for the information.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-23 : 03:48:42
Run this to know how single quotes work

select '','''','''''','''''''',''''''''''

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

saini_balvinder
Starting Member

22 Posts

Posted - 2008-01-23 : 04:12:18
the db table does not have any single quote. it is plain text or number. but when exporting to excel single quote comes for each cell. how to make sure that in excel the same data is displayed which is there in table?

do i still have to use replace function in select statement?

but table does not have any single quote.
Go to Top of Page

saini_balvinder
Starting Member

22 Posts

Posted - 2008-01-23 : 23:42:12
one more thing guys... if i export data directly from table (right click on table name --> All Tasks --> Export data) and export it to excel i get single quotes in front of all cells. However the data in db table does not have single quotes.

how to avoid this?
Go to Top of Page
   

- Advertisement -