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.
For last few days I am troubling with an SSIS package to configure an Excel source that contain different types of data. And I have configured it to unicode (DT_WSTR) for all columns, but while loading some them are implicitly converted to float. I could see them in the data viewer. This happens for some numeric fields. And the data in the numeric column looks like below.
1
0.5
1
0.5
I tried all the ways in my knowledge. adding IMEX=1 and TypeGuessRows=0 and ValidateExternalMetadata= False etc.
You have to add IMEX=1 to the connection string, and you can try adding a dummy row which contains string values after the column header, as example:
Column1 Column2 Column3
aaa aaa aaa
1 1 0.5
2 0.5 1
Or just select that the first row doesn't contains column header, and skip the first rows in the import process (it can be done by adding HDR=NO to the connection string)
I have 4 excel files and I wanted to insert the data from these 4 excel files to a single database file in MSSQL.
1st Excel file - 10 rows
2nd Excel file - 20 rows
3rd Excel file - 30 rows
4th Excel file - 40 rows
The table in MSSQL should have 100 rows after the task. Thw column names are similar in all the files.
I have taken
tfileInputExcel1 -> tMap -> tMSSQLOutput
tfileInputExcel2
tfileInputExcel3
tfileInputExcel4
All mapped to the same tMap.
I just don´t know how to Map different input sources to a single tMap. I have been searching on the internet on this but I haven¨t find any relevant for my need. Can anyone here help me out on how to map tMap to a multiple input and output sources.
Try this way:
tFileList (with the appropriate file mask)-tFileInputExcel-tMap-tMSSqlOutput
or if you want just one interaction with the database:
tFileList (with the appropriate file mask)-tFileInputExcel-tMap-tHashOutput
onSubJobOk
tHashInput-tMSSqlOutput
Note the tMap is necessary only if you have to transform the input data
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.