January 12, 2010 at 8:20 am
I have written a query na d add to take out the CRLF's but now it stops and will not export the rest of the query to excel.
REPLACE(RTRIM(dbo.Table Name.Column),char(13)+ Char(10),'') AS 'Column1',
RTRIM(dbo.Table Name.Column) AS 'Column2'
Can anyone tell me why it is not exporting the next row?
January 12, 2010 at 10:06 am
There are lots of people here that can help you. However you first need to help us help you. You need to post some table definitions, inserts for some temp data, and what you want that data to look like. It is impossible to tell what is wrong with a snippet of a query.
_______________________________________________________________
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/
January 12, 2010 at 10:29 am
SELECTDISTINCT
dbo.MyTable.MyColumn AS 'Column1',
RTRIM(dbo.MyTable.MyColumn ) AS 'Column2',
RTRIM(dbo.MyTable.MyColumn ) AS Column3',
Replace(Rtrim(Ltrim(Replace(replace(dbo.MyTable.MyColumn , Char(13),''),Char(10),''))),',','') AS 'Column4',
--REPLACE(RTRIM(dbo.MyTable.MyColumn ), Char(13)+ Char(10),'') AS 'Column4',
RTRIM(dbo.MyTable.MyColumn ) AS 'Column5',
RTRIM(dbo.MyTable.MyColumn ) AS 'Column6',
dbo.MyTable.MyColumn AS 'Column7',
dbo.MyTable.MyColumn AS Column8',
ISNULL (dbo.MyTable.MyColumn ,'') AS 'Column9',
ISNULL (dbo.MyTable.MyColumn ,'') AS 'Column10',
dbo.MyTable.MyColumn AS 'Column11',
dbo.MyTable.MyColumn AS 'Column12',
dbo.MyTable.MyColumn AS 'Column13',
dbo.MyTable.MyColumn AS 'Column14',
dbo.MyTable.MyColumn AS 'Column15',
dbo.MyTable.MyColumn AS 'Column16',
dbo.MyTable.MyColumn AS 'Column17'
FROMdbo.MyTable(NOLOCK) INNER JOIN
dbo.MyTable(NOLOCK) ON
dbo.MyTable.MyColumn = dbo.MyTable.MyColumn LEFT OUTER JOIN
dbo.MyTable(NOLOCK) ON
dbo.MyTable.MyColumn = dbo.MyTable.MyColumn LEFT OUTER JOIN
dbo.MyTable(NOLOCK) ON
dbo.MyTable.MyColumn = dbo.MyTable.MyColumn LEFT OUTER JOIN
dbo.MyTable(NOLOCK) ON
dbo.MyTable.MyColumn = dbo.MyTable.MyColumn LEFT OUTER JOIN
dbo.MyTable(NOLOCK) ON
dbo.MyTable.MyColumn = dbo.MyTable.MyColumn
LEFT JOIN
dbo.MyTable(NOLOCK) ON
dbo.MyTable.MyColumn = dbo.MyTable.MyColumn
Where dbo.MyTable.MyColumn in (13,54,92,111,61,60)
January 12, 2010 at 11:43 am
I don't quite understand the problem. You say:
"...Can anyone tell me why it is not exporting the next row? ..."
Does that mean 1 entire row (all fields) is ok, then it stops ?
As Sean said: "...You need to post some table definitions, inserts for some temp data, and what you want that data to look like...." In other words, what does the raw data look like, and what should it look like afterwards.
January 12, 2010 at 12:15 pm
When running this job it stops writing to excel where I have;
Replace(Rtrim(Ltrim(Replace(replace(dbo.MyTable.MyColumn, Char(13),''),Char(10),''))),',','') AS 'Column4', ---this one exports
After this line it will not export the rest of the query, if I place it at the bottom everything will export but I need it in column4.
Make sense?
And if I run it in Query Analyzer it shows that nothing is wrong.
January 12, 2010 at 6:36 pm
Well .... ?
January 12, 2010 at 7:51 pm
SQL Girl,
I have three thoughts on this:
1. Despite repeated requests, you have yet to provide any DDL / DML (CREATE TABLE / INSERT) statements to demonstrate this problem. This will help out all of us non-paid volunteers tremendously. Please read the first link in my signature for more details about this.
2. I see that in addition to removing the CR/LF, you are also removing commas. This is the only column where you are removing anything. This makes me wonder if there is something else in this column that is causing things to screw up. Again, if we had some DDL/DML, we could discern this.
3. Have you tried pumping the data from the select into a temp table, and from there pushing it to Excel?
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply