Conversion of string to data(Flat file to sql server) Transformations
Hi All,
I have a requirement in which I am trying to convert a field of type string which contains date from source file to field of type datetime in sqlserver by using all the below expressions
to_date(DATE, 'yyyy/mm/dd-hh24:mi:ss' )
to_date(DATE, 'yyyy/mm/dd' )
However it is not throwing any errors but the data of the date field is being loaded with null values(Date is present in flat file).
Any inputs plz???
Thanks
U
Can you post a sample of the date string you are trying to convert?
Similar Messages
-
Extra column to be added while importing data from flat file to SQL Server
I have 3 flat files with only one column in a table.
The file names are bars, mounds & mini-bars.
Table 'prd_type' has columns 'typeid' & 'typename' where typeid is auto-incremented and typename is bars, mounds & mini-bars.
I Import data from 3 files to prd_details table. This table has columns 'pid', 'typeid' & 'pname' where pid is auto-incremented and pname is mapped to flat files and get info from them, now i wanted the typeid info to be received from prd_type table.
Can someone please suggest me on this?You can get it as follows
Assuming you've three separate data flow tasks for three files you can do this
1. Add a new column to pipeline using derived column transformation and hardcode it to bars, mounds or mini-bars depending on the source
2. Add a look task based on prd_type table. use query as
SELECT typeid,typename
FROM prd_type
Use full cache option
Add lookup based on derived column. new column -> prd_type.typename relationship. Select typeid as output column
3. In the final OLEDB destination task map the typeid column to tables typeid column.
In case you use single data flow task you need to include a logic based on filename or something to get the hardcoded type value as bars, mounds or mini-bars in the data pipeline
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Issue importing flat files into SQL server 2008R2
I have csv files that the last column may not have data. SSIS (version 2008R2) will insert the next row's data into the empty cells, which causes my package to fail.
I know this is resolved in 2012 but we are using 2008R2 still. Any suggestions?
Thanks.Hi sqlBI2014,
After testing the issue that Flat File Connection Manager cannot handle file with uneven number of columns in each row in my SQL Server 2008 R2 environment, I can reproduce it.
Based on my research, the issue is caused by the Column Delimiter gets first preference and then Row delimiter. So the next row data would be inserted in the empty column cell. This is by design in SQL Server 2005, SQL Server 2008 or SQL Server 2008 R2.
Good news is that the issue is fixed in SQL Server Data Tools which comes with SQL Server 2012. In SQL Server 2012, by default, the Flat File Connection Manager always checks for a row delimiter in unquoted data, and starts a new row when a row delimiter
is found. This enables the connection manager to correctly parse files with rows that are missing column fields.
If you still want to fix the issue in SQL Server 2008 R2, there is a sample component posted to the CodePlex that might help you with this:
http://ssisdfs.codeplex.com/
References:
http://blogs.msdn.com/b/dataaccesstechnologies/archive/2013/03/13/flat-file-source-cannot-handle-file-with-uneven-number-of-columns-in-each-row.aspx
https://connect.microsoft.com/SQLServer/feedback/details/293193/ssis-import-of-flat-file-with-uneven-number-of-columns
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Convert from String to Date for storing in SQL Server 2000
Hi,
I've accepted some values from a user using a form in HTML.Now using Servlets I transfer the value to my java code .
I want to know how can I convert a DATE accepted from the user thats presently in "String" format to the "datetime" format for SQL Server2000.
Please guide me with some steps and I shall be grateful.
ThanksThe java.text.SImpleDateFormat class is most probably of use.
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String enteredDate = "25/12/2006";
java.util.Date utilDate = sdf.parse(enteredDate);
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());You can then use the java.sql.Date with the "setDate()" method of a prepared statement. This method would be database independant, as you are setting an actual date, not depending on a specific format on the database end. -
Copying TEXT column from flat file into SQL results in empty fields....
I'm copying TEXT column from SQL to Flat file (ragged right fixed width) - DT_TEXT. It copies fine and I''ve checked the output file. Now, while trying to copy the flat file to sql server in another system. I find all the fields are empty.
When I preview the source from flatfile, I see all the entries there. But it copies other fields but the field with DT_TEXT is empty.
This is when I preview
SQL Table output
Any help will be helpful!!!Hi, I'm not sure If I'm understanding what you're saying. The data got copied from SQL to Flat file. I've double checked the flat file and I see the DT_TEXT data there. The size of file also gives an indication that there's existence of TEXT Data
But, when I copy that data back to sql again (which I can also preview before the load), The DT_TEXT values goes missing. Same when I copy to Excel as CSV or as a Flat file. I don't see text data.
The TEXT data resides on the first output. But when I try to extract to other format from that output, it doesn't come out. -
SSIS 2008 R2 - Export data to Flat File in another server
Hello Everybody,
I'm trying to export data from a table in database server to flat file in another server, however it is happening the error Access Denied. I'm using SQL Server Integration Service 2008 R2 to do this.
I've checked all the ways that's happening could the level of security and could not resolve.
Please could someone tell me what I'm missing in this case?
Following error log:
SSIS package "AtualizarDados.dtsx" starting.
Information: 0x4004300A at Gerar arquivo, SSIS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at Gerar arquivo, SSIS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Gerar arquivo, SSIS.Pipeline: Pre-Execute phase is beginning.
Information: 0x402090DC at Gerar arquivo, Geração de Arquivo [63]: The processing of file "\\targetserver\Export_File\Export_File.txt" has started.
Warning: 0x80070005 at Gerar arquivo, Geração de Arquivo [63]: Access is denied.
Error: 0xC020200E at Gerar arquivo, Geração de Arquivo [63]: Cannot open the datafile "\\targetserver\Export_File\Export_File.txt".
Error: 0xC004701A at Gerar arquivo, SSIS.Pipeline: component "Geração de Arquivo" (63) failed the pre-execute phase and returned error code 0xC020200E.
Information: 0x40043008 at Gerar arquivo, SSIS.Pipeline: Post Execute phase is beginning.
Information: 0x402090DD at Gerar arquivo para DMZ, Geração de Arquivo [63]: The processing of file "\\targetserver\Export_File\Export_File.txt" has ended.
Information: 0x4004300B at Gerar arquivo, SSIS.Pipeline: "component "Geração de Arquivo" (63)" wrote 0 rows.
Information: 0x40043009 at Gerar arquivo, SSIS.Pipeline: Cleanup phase is beginning.
Task failed: Gerar arquivo
SSIS package "AtualizarDados.dtsx" finished: Success.
Regards,
Antonio EstimaI got after using domain user.
Thanks to all -
Master Data Flat File Loading Error
Hi guys.
I received the following error when try to preview a master data flat file.
109 ENDIF.
110 ENDIF.
May I know how to solve this?
Thanks!Fulham,
Please give us the nature of data you are loading and also try and simulate the same and see if it goes through.
What are the infoobjects you are loading for the master data ...?
Arun -
Putting Flat file on Application Server
Hi,
I am using following report to transfer a flat file to application server.
REPORT Z_DOWNLOAD.
PARAMETERS: P_FILE LIKE IBIPPARMS-PATH,
P_FILE1(100) default '/usr/sap/put' lower case.
DATA: WS_FILE TYPE STRING.
DATA: BEGIN OF T_DATA OCCURS 0,
RECORD(200),
END OF T_DATA.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_FILE
START-OF-SELECTION.
WS_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = WS_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = T_DATA
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Creating the file at Appl ...........
OPEN DATASET P_FILE1 FOR OUTPUT IN TEXT MODE encoding utf-8.
if sy-subrc ne 0.
message e000(--) with 'Error in opening file'.
endif.
Trasfer the records to file.............
loop at t_data.
transfer t_data to p_file1.
endloop.
close dataset p_file1.
if sy-subrc eq 0.
write: / 'Written the files at ', p_file1.
Now when I am uploading Flat file1 with following data it gets updated but when I use Flat file2, it does not work.
Please help me out..
I am posting the data of both flat files.
Flat file1:(File getting transferred successfully to application server)
1,NPOBL,ABC
1,NPOBL,CDE
1,NPOBL,FGH
Flat file2: (Getting error when trying to transfer this file on application server)
DS04,1,NPOBL,200,CREATE1,NEW YORK,X
DS04,1,NPOBL,200,CREATE2,NEW YORK,X
DS04,1,NPOBL,200,CREATE3,NEW YORK,X
<b>Please help me out...</b>
-Tusharhi Rajesh,
I guess your in ternal table is not able to hold the data as is of 200 characters ... try increasing the length ..
DATA: BEGIN OF T_DATA OCCURS 0,
RECORD(2000),
END OF T_DATA.
Regards,
Santosh -
Load Flat File from App Server
HI, all.
I want load flat file from appliation server. I created CSV file and loaded it on app. server with FM ARCHIVEFILE_CLIENT_TO_SERVER. After I created datasource and tried load data in the infocube. In this procedure I encountered with two problem
1. When I look file in AL11, I doesn't see cyrillic symbols, instead this symbols I see #.
2. When I try load data with data source, I get exception RS_EXCEPTION 000 "File don't open"
Anybody can help me resolve this problem?
wbr, Fanil.Hi, kodanda pani KV.
2. File is was closed.
1. Can me you clearly explain what you meen?
wbr, Fanil -
Logical path for getting a Flat file from application server
Hi All,
We have loaded some .csv files to application server, what is the logical path we have to mention in the infopackage scheduler screen? please guide me how to give the path for getting a flat file from application server.
Thanks,
Sairam.Hi Sairam,
I hope you know which location you have saved in the Application server.
Now if you go to the Infopackage and click on the "External Data" tab, there you will see Radio Buttons for
1) Client Workstation
2) Application Server
Choose the second radio button, then in the Field "Name of the File" you will be able to use the F4 help and browse AL11 transaction through this option. You can then choose the File.
Hope this helps
Regards,
Praveen. -
How to create a inbound IDOC from flat file in Application server
HI All
Our requirement is to create the Inbound idocs from a flat file from application server with in R/3
Could any body please let me know the steps required for this.
Thanks
Malli1. Read the file using OPEN DATASET and read and fill up the segment info and fill the EDIDC header data
and then call function
CALL FUNCTION 'INBOUND_IDOC_PROCESS'
TABLES
IDOC_CONTROL = i_edidc
IDOC_DATA = i_edid4.
a® -
Creation of Flat file in Application Server
Hi,
Can you please clarify what is Logical file path and Physical file pathe.
Also how to create a flat file in Application Server with Logical and Physical file paths.
ThanksHi Yasaswini,
Physical file is what you see from the OS level.
Logical file is what ABAP code can call certain functions to read/write.
Transaction FILE would link them together. Typically the logical path ends with "<FILENAME>", and the logical file refers to the logical path. You can check the help for more info.
http://help.sap.com//saphelp_erp2004/helpdata/EN/8d/3e4edc462a11d189000000e8323d3a/frameset.htm
Good luck,
Victor -
hi,
am running the below command for moving sql serevr mdf and ldf files from one drive to another : c drive to d drive:
but am getting the below error
SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\abc.mdf". Operating system error 2: "2(The system cannot find the file specified.)".
use master
DECLARE @DBName nvarchar(50)
SET @DBName = 'CMP_143'
DECLARE @RC int
EXEC @RC = sp_detach_db @DBName
DECLARE @NewPath nvarchar(1000)
--SET @NewPath = 'E:\Data\Microsoft SQL Server\Data\';
SET @NewPath = 'D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\';
DECLARE @OldPath nvarchar(1000)
SET @OldPath = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\';
DECLARE @DBFileName nvarchar(100)
SET @DBFileName = @DBName + '.mdf';
DECLARE @LogFileName nvarchar(100)
SET @LogFileName = @DBName + '_log.ldf';
DECLARE @SRCData nvarchar(1000)
SET @SRCData = @OldPath + @DBFileName;
DECLARE @SRCLog nvarchar(1000)
SET @SRCLog = @OldPath + @LogFileName;
DECLARE @DESTData nvarchar(1000)
SET @DESTData = @NewPath + @DBFileName;
DECLARE @DESTLog nvarchar(1000)
SET @DESTLog = @NewPath + @LogFileName;
DECLARE @FILEPATH nvarchar(1000);
DECLARE @LOGPATH nvarchar(1000);
SET @FILEPATH = N'xcopy /Y "' + @SRCData + N'" "' + @NewPath + '"';
SET @LOGPATH = N'xcopy /Y "' + @SRCLog + N'" "' + @NewPath + '"';
exec xp_cmdshell @FILEPATH;
exec xp_cmdshell @LOGPATH;
EXEC @RC = sp_attach_db @DBName, @DESTData, @DESTLog
go
can anyone pls help how to set the db offline. currently i stopped the sql server services from services.msc and started the sql server agent.
should i stop both services for moving from one drive to another?
note: I tried teh below solution but this didint work:
ALTER DATABASE <DBName> SET OFFLINE WITH ROLLBACK IMMEDIATE
Update:
now am getting the message :
Msg 15010, Level 16, State 1, Procedure sp_detach_db, Line 40
The database 'CMP_143' does not exist. Supply a valid database name. To see available databases, use sys.databases.
(3 row(s) affected)
(3 row(s) affected)
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\CMP_143.mdf". Operating system error 2: "2(The system cannot find the file specified.)".First you should have checked the database mdf/ldf name and location by using the command
Use CMP_143
Go
Sp_helpfile
Looks like your database CMP_143 was successfully detached but mdf/ldf location or name was different that is why it did not get copied to target location.
Database is already detached that’s why db offline failed
Msg 15010, Level 16, State 1, Procedure sp_detach_db, Line 40
The database 'CMP_143' does not exist. Supply a valid database name. To see available databases, use sys.databases.
EXEC @RC = sp_attach_db @DBName, @DESTData, @DESTLog
Attached step is failing as there is no mdf file
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\CMP_143.mdf". Operating system error 2: "2(The system cannot find the file specified.)"
Solution:
Search for the physical files(mdf/ldf) in the OS and copy to target location and the re-run sp_attach_db with right location and name of mdf/ldf. -
Importing Data From XLS File to SQL Server
Dear All,
I want to import the data from Excel(.xls) file to SQL Server (2008 R2). But due to some problem (may be data), an error is occurring when I am going to import using Import Data Wizard. I want the rows to ignore those are creating issues and to keep track
of those records. That's why I need to process rows one by one. How can I do it? Any idea?
Thanks & Regards,
Anujit Karmakar
Anujit Karmakar Sr. Software EngineerWhats the error? Have you mapped the source-destination data types in column mappings?
Below is a link to video to guide you through the Steps of Import/Export Wizard
SSIS Wizard Video: http://www.youtube.com/watch?v=9Wmdhnx1niU
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other
forum members can benefit from it -
How to Post a file(Flat File ) into Application server of the XI(AL11)?
How to Post a file(Flat File ) into Application server of the XI(AL11)?
Best Regards,
JoseHi,
1) goto SXDA_TOOLS Transaction code
2) Provide the Following details
Object Type : DXPROJECT
Program Type: BAPI
Program/Method: CREATE
3) Click on Copy Button
4) Select the Source as Presentation Server
a) Select the File where you saved in your Local machine
5) Select the Target as Application server
a) Check the check box Remote Server
b) Select the File type as Physical
c) In File name give /usr/sap/SSD/DVEBMGS00/work\Your file name (This the Server path
Where the file is going to save)
6) Click on Continue
Go to AL11 and check whether the File has been create in the following path /usr/sap/SSD/DVEBMGS00/work
Provide this path in the Communication channel path when you select the Transport Protocol as NFS and you place the file in AL11 directory.
Regards
Seshagiri
Maybe you are looking for
-
G4 Flat-panel No Longer stays up!?! What the heck?
Can anyone advise on how to repair my G4 flat panel? The screen no longer wants to stay up. It continues to fall as though there is no spring or resistance. I've attempted to look this issue up so as not to repeat a question, but I can't find anythin
-
Hi there i have a costumer´s Powerbook G4 with this problem The issue is on the mainboard, flex, LCD, video card? Regards
-
Reminders and how to get them into MS Outlook 2007
Has anyone worked this one out. I have tried everything i know but to no avail. Thanks
-
How can i call a DLL file using invoke node from labview?
I cant call a DDL function using call library function.so plz tell me how to use invoke node and call DLL using invoke node Please Mark the solution as accepted if your problem is solved and donate kudoes
-
Java applet won't run: ClassFormatError: Unknown constant tag 115
Hi, About two years ago I uploaded an applet to a server and it ran fine. Since then I've done minor tweaks to the applet and it works on my computer, but I recently uploaded it to a new server and now it gives me the following: java.lang.ClassFormat