I'm having a strange problem with SSIS. I'm exporting some data from a database into a flat file. It comes out all fine - except that rather than displaying the data like this:
ID FirstName LastName Age
It comes out like this:
ID FirstName LastName Age ID1 FirstName1 LastName1 Age1
Now, its not repeating the same data (ever), so the data might realistically look like this:
1 John Doe 23 2 Jane Doe 22
Why is it repeating like this?
In a fixed-width destination (even though it's "text") - it's really fixed width records (just in a text representation in the code page of your choice), one after another with nothing in between them. So you need to add a record/row delimiter - in this case CRLF.
If you are in a Flat file destination component and click the new button to crete a destination data adapter right there - the "wizard" gives you four options. The difference between fixed-width and fixed-width with row delimiters is that it just puts a little CRLF column on the end.
It sounds to me like the row delimiter from your file source is wrong. It's reading in two or more rows as one row.
What are the output columns listed on the flat file source? If you see all of those you listed, I would almost guarantee this is the issue.
What is the actual layout of the source file? Is it delimited, fixed width columns, etc?
Related
I have a flat file which doesn't have the header record. The data except the trailing record is like a fixed width flat file with no delimiters.
Data in flat file looks like:
TOM ROLLS
DAVECHILLS
TOTAL2XYZ
Fixed Width data(first 2 lines as shown in the above flat file data)
ColumnName Start position End position
Name 1 4
Last_name 5 9
I want to load the data(till trailing record) in data_table and the trailing record(starting with Total) in another table. The data in the total table should look like
c1 c2
2 XYZ
For the data table, I am currently using "fixed width" and dividing the data into different column and it is working fine. Can you please help to load this last trailing record in a different table(Total table as discussed above)
You have not provided enough data for me to test because I can find several methods to load one row and accomplish what you are asking but those methods not necessarily work with multiple rows depending on the structure of you source data.
On the surface it appears that you simply need to make another flat file connection and define the starting and end position to extract only the data for the second table.
Relatively new to PBI and need a hand with counting totals of delimited values in a single column. So my source column looks something like:
ID Code
1 abc1|bcd2
2 def2|abc1|ghi3
3 bcd2
I've created a new table based on the same query that takes just this column and splits it into individual rows by the pipe delimiter:
Individual Codes
abc1
bcd2
def2
ghi3
Now I'd like to plot the number of occurences of each individual code in the original code column. I had intended on doing this using a calculated column, but I don't know if that's even the best approach. So having something like:
Individual
Codes Counts
abc1 2
bcd2 2
def2 1
ghi3 1
If it's possible to relate the tables, I'm not sure how. I've tried filter approaches similar to this but that's caused crashes. The current source data has maybe 50k rows (with 8k individual codes), but potentially these values could be 10-100x larger so I imagine it's best to avoid something that's creating filters of the source data for each row of the Individual Code table.
Much appreciated!
Original Data
Then you can split Your code column into new rows using delimiter
and then you can group your rows based on Code and count rows as below
and when you come back to Visualizations you can have your desired output
I have SSRS report data where we will have two different thing in some of the cells, For example:
Old Values in SourceDB
FirstName LastName
Robin Son
BOB Alice
Updating the DB values:
FirstName LastName
Robin S
BOB A
After some update, we will have the changes and new & old values in Audit Table so the report will be created like this.
FirstName LastName
Robin was: Son now: S
BOB Was: Allice now: A
Is it possible to have the Was value in Red color and the now value in Green Color.
In worst case if it is not possible how to make the whole cell value into red.
Thanks for the suggestions or answers or even feedback's are appreciated.
If you can't change your Audit table per Ashiko's very sensible recommendation to hold the Was and Now values in seperate columns, you will need to parse out the relevant parts of your string value in your report.
One way you can do this is through placeholders that have expression based values. In your SSRS table, add 4 placeholders to a table that is based on your Audit dataset, with the following expressions as their Label and Value:
Was: - ="Was: "
Old Value - =replace(left(Fields!LastName.Value,instr(Fields!LastName.Value," Now:")-1),"Was: ","")
Now: - ="Now: "
New Value - =mid(Fields!LastName.Value,instrrev(Fields!LastName.Value,":")+2,99999)
You can then format the individual placeholder items as you would normal text, with some one colour and others another.
If you do this correctly, you should end up with something like this:
Design View:
Rendered:
Do be aware though, that if you do resort to splitting your string values in this manner, if that pattern you are searching for (eg: Now: in the old value or : in your new value) you will get undesirable results in your report.
If this is an entirely internal report for monitoring purposes, this is probably not an issue. If this will be customer facing however, I strongly recommend that you add additional columns to your Audit table for the Old and New value to allow you absolute control.
Did you try this?
Select the cell
Click F4 to open cell properties or right click the properties
In font tab , Select Color
4 Select Underneath Expression
5 Write as
=iif(Fields!ColumnName.Value = "WAS","Red","Green")
I'm attempting to copy a query result from SSMS to excel. I selected "copy with headers" and pasted it into Excel. My data set has 9 columns. When I paste the data into excel, information from column 9 ends spread across columns 9, 10 and 1 It looks like this:
A B C D E F G H I -Column Heading
A B C D E F G H I I -Data
I
(blank row)
I've reviewed the query results in SSMS and this is not occurring in the original data. When the value in column F is NULL the additional row and information in column 10 do not occur. Thus far I have tried the following:
-When I remove column 9 from the query then copy & paste, column 8 is spread across 8, 9, and 1.
-I've also created a brand new spreadsheet, made sure to clear any formatting and tried the copy & paste.
-I saved the query results as a .csv file and imported it into Excel. I still got the same result.
-I copied the columns individually one at a time. The the information in the 8th column ends up on two lines paired with the other columns of the next row. So each item in column 8 becomes another row offset downwards until there are many more values in column 8 than other columns. Where the value in column 8 is NULL, this does not occur.
-I removed all the other items from the query result so that only the values of columns 8 and 9 are returned. All information from column 9 ends up in column 8 followed by a blank row.
Returning 8 alone, each item returned ends up on two rows.
Returning 9 alone, the data is pasted correctly.
The headers are always in the right place. From what I can surmise, the data in column 8 is the culprit here. The data type is a varchar(max) which allows nulls. The information included is in the following format,
(TC Date & Time, Last Name, First Name) Comments
Moving SSMS query results into Excel to make tables is something I do frequently. However I have never before encountered this result. Hopefully my explanation is thorough enough so someone can tell me how to correct this error. Thanks!
Replace feed and Carriage returns from your dataset before you can paste into Excel, Try something like this on the columns you are having issues and then try to paste it in excel:
SELECT REPLACE(REPLACE(yourcolumnname, CHAR(13),' '), CHAR(10),' ')
FROM table
This is probably due to using 'Text to columns' recently in Excel. That splits columns using some rule. Columns need to be set back to 'tab delimited'.
For the offending column:
Data → Text to Columns
Original Data Type: Check Delimited
Click Next
Delimiters: check 'Tab', uncheck anything else.
Click Next
Click Finish
SSMS copy-paste does not preserve data types. Excel tries to parse the string and splits it into additional columns or even lines.
I develop SSMSBoost add-in and we have covered this in our video, which explains 3 different ways of exporting the data into Excel without data loss (data type information is preserved): (Copy-Paste in native excel format, XML export, .dqy Query) https://youtu.be/waDCukeXeLU
My data file looks like
1234567 7654321
TEXT ABOUT STUFF
ON MULTIPLE LINES
NOT SURE HOW MANY
1234567 7654321
TEXT ABOUT STUFF
ON MULTIPLE LINES
NOT SURE HOW MANY
The only thing for certain is a new record starts with 2 sets of numbers that are 7 characters long. The numbers are also on a new line and appear as my sample data above.
I am using SQL Server Express on Windows 8.
Ultimately I need the first group of numbers in a column, 2nd group in another column and the remainder of the text in the 3rd column.
This is the realm of ETL. The SQL Server was of doing this is to use SSIS.