June 20, 2013 at 10:20 am
Hi Guru's
I'm trying to run a Select on an entire table Via
Select * From
However a couple of the columns contain addresses with the NewLine Cahrachter embedded in it which is ruining my export to Excel.
I know that I can run a REPLACE(REPLACE(REPLACE(MyField, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')
on a specific field, my question is how to do this on the entire selection?
Thanks.
June 20, 2013 at 10:32 am
You say:
However a couple of the columns contain addresses with the NewLine Cahrachter embedded in it which is ruining my export to Excel
So if it's just a couple of columns, why not use the REPLACE method on the two Address columns and explicitely list the remaining columns as normal? Or am I missing something?
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
June 20, 2013 at 10:59 am
There are 257 Columns in the table and there are 3 or 4 columns with a ReturnCharachter.
June 20, 2013 at 11:07 am
Right click on the table and and generate the select statement to a query window and then edit the 3 or 4 columns that require the replace function. You won't have to type it all out this way.
June 20, 2013 at 12:10 pm
miker 8667 (6/20/2013)
There are 257 Columns in the table and there are 3 or 4 columns with a ReturnCharachter.
257 columns and a select *??? Unless this is a DW that amount of columns sounds like some normalization is in order.
You can get a very easy comma separated list of all columns by expanding the table in the Object Explorer, then just drag the columns "folder" to a query window. Super simple. 🙂
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 20, 2013 at 12:16 pm
Thanks a lot. I did not know about that possibility.
About the 257 Columns, question an SAP ERP system!
Thanks again for your help.
June 20, 2013 at 12:19 pm
miker 8667 (6/20/2013)
Thanks a lot. I did not know about that possibility.About the 257 Columns, question an SAP ERP system!
Thanks again for your help.
Gotta love those ugly things. Glad my suggestion helped.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply