Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Remove NewLine Charachters on a Select All. Expand / Collapse
Author
Message
Posted Thursday, June 20, 2013 10:20 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 30, 2013 9:58 AM
Points: 10, Visits: 35
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.
Post #1465822
Posted Thursday, June 20, 2013 10:32 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Friday, October 31, 2014 10:27 AM
Points: 708, Visits: 3,293
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

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
Post #1465834
Posted Thursday, June 20, 2013 10:59 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 30, 2013 9:58 AM
Points: 10, Visits: 35
There are 257 Columns in the table and there are 3 or 4 columns with a ReturnCharachter.
Post #1465849
Posted Thursday, June 20, 2013 11:07 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 2:14 PM
Points: 207, Visits: 1,536
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.
Post #1465853
Posted Thursday, June 20, 2013 12:10 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:10 AM
Points: 13,230, Visits: 12,709
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1465880
Posted Thursday, June 20, 2013 12:16 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 30, 2013 9:58 AM
Points: 10, Visits: 35
Thanks a lot. I did not know about that possibility.

About the 257 Columns, question an SAP ERP system!

Thanks again for your help.
Post #1465886
Posted Thursday, June 20, 2013 12:19 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:10 AM
Points: 13,230, Visits: 12,709
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1465890
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse