Solved

Removing boxes from Excel spreadsheet--data pulled from SQL View

Posted on 2007-03-19
8
196 Views
Last Modified: 2010-03-20
I have a SQL view that I'm pulling into Excel using an ODBC connection/Microsoft Query.   My issue is that the notes field has boxes/squares wherever there were carriage returns in the SQL notes field.

Is there a way in SQL to strip those out in my view before bringing them into Excel?   Or is there a function I could write in a macro to do the same thing with the data is refreshed?

Thanks!
0
Comment
Question by:colorbok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 11

Expert Comment

by:flipz
ID: 18749624
you should be able to pull the column out such as

select   REPLACE(ColumnName, CHAR(13), '') as NewColumnName
0
 

Author Comment

by:colorbok
ID: 18749712
I receive the following error when I run that REPLACE function:

Server:  Msg 8116, Level 16, State 1, Line 1
Argument data type text is invalid for argument 1 of replace function.

Please advise.   Thanks!
0
 
LVL 16

Accepted Solution

by:
rboyd56 earned 125 total points
ID: 18749778
Try this in a macro in Excel:

Worksheets("Sheet1").Columns("I").Replace What:=vbCrLf, Replacement:="?"

Should be self explanatory, the vbCrLf is the VB code for a carriage return and just replace the ? with whatever you want in place of the carriage return.

This came from:

http://www.gossamer-threads.com/forum/General_C8/Databases_and_SQL_F36/Delete_Carriage_return_query_P259718/
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 16

Expert Comment

by:rboyd56
ID: 18749800
0
 

Author Comment

by:colorbok
ID: 18749825
That worked.   Thanks rboyd56!

Thanks for trying flipz---I don't know why that didn't work.
0
 
LVL 16

Expert Comment

by:rboyd56
ID: 18749874
The replae function does not work on a SQL Server text column. It will only work on a char, varchar, nchar or nvarchar column
0
 
LVL 11

Expert Comment

by:flipz
ID: 18749876
Apparently the REPLACE function doesn't work on some column datatypes - go figure!
0
 
LVL 16

Expert Comment

by:rboyd56
ID: 18749903
For text columns you have to use readtext, updatetext and writetest. It is not an easy thing to do.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question