Multi Format Text File

Apr 5, 2007

Hello. I am in the process of migrating an old app to SQL Server. The old app reads hundreds of different flat file formats. One of the more complex ones is a multi-format delimited file. For example:

01^Bob Johnson^123 Main St^Anytown^St
02^Book1^$20
02^Book2^$30
03^Gift Cert^Happy Birthday^$100

This file is delimited with the ^ character. Note that the first 2 characters identify the row type. All 01 rows have data in the format: Name, Street Address, City, State. All 02 have data in the format: Book name, price. Etc.

Any clever ideas on how to parse this? I tried setting it up as a flat file source with the ^ delimiter. It doesn't work - in this example it wraps the third row to the end of the second row and keeps adding columns to fill out the row.

The only option that I can think of is to pull the entire row into one long column, and then use a script component to manually substring each column out.

Any help would be greatly appreciated.

Thanks,
Chris

View 7 Replies


ADVERTISEMENT

Import Multi-Row Record Text File With DTS

Apr 9, 2004

I have a text file I need to import into a SQL Server table. Each record spans several lines. Does anyone have a vbscript routine that wil go thru this text file and put each record on one row? Once the records are one row, DTS will easily handle the import. Or is there a better way?

Sample multi-row records:

WRLDWYXCDS1 ALT101 APR04 21:30:24 6879 FAIL ALT
HOST 00 0 08 00 DN 3073477171 1st CYCLE
TEST TYPE CKTTST DIAGNOSTIC RESULT BIC/EBS LC TRBL:PTRN 000E S= 1 R= 0
ACTION REQUIRED Replace Card CARD TYPE 6X21AC

WRLDWYXCDS1 ALT101 APR04 22:31:37 7672 FAIL ALT
HOST 00 0 08 00 DN 3073477171 1st CYCLE
TEST TYPE CKTTST DIAGNOSTIC RESULT BIC/EBS LC TRBL:PTRN 000E S= 1 R= 0
ACTION REQUIRED Replace Card CARD TYPE 6X21AC

View 3 Replies View Related

XML Format File For Bulk Insert Of Text File With Fixed Length Columns

Jan 2, 2008

Hey All,

Similar to a previous post (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=244646&SiteID=1), I am trying to import data into a SQL Table.

I am trying to program a small application that will import product data obtained through suppliers via CD-ROM. One supplier in particular uses Fixed width colums, and data looks like this:




Example of Data

0124015Apple Crate 32.12

0124016Bananna Box 12.56

0124017Mango Carton 15.98

0124018Seedless Watermelon 42.98
My Table would then have:
ProductID as int
Name as text
Cost as money

How would I go about extracting the data with an XML Format file? I am stumbling over how to tell it where to start picking up data for a specific column.
Is there any way that I could trim the Name column (i.e.: "Mango Carton " --> "Mango Carton")?

I don't know if it makes any difference, but I've been calling SQL from my code by doing this:




Code in C# Form

SqlConnection SqlConnection = new SqlConnection(global::SQLClients.Properties.Settings.Default.ClientPhonebookConnectionString);
SqlCommand cmd = new SqlCommand();

cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO PhonebookTable(Name, PhoneNumber) VALUES('" + txtName.Text.ToString() + "', '" + txtPhoneNumber.Text.ToString() + "')";
cmd.Connection = SqlConnection;

SqlConnection.Open();
cmd.ExecuteNonQuery();
SqlConnection.Close();
RefreshData();
I am running Visual Studio C# Express 2005 and SQL Server Express 2005.



Thanks for your time,


Hayden.

View 1 Replies View Related

SSIS: Merge Problem: The Input Is Not Sorted (for Use In Exporting A Multi-record Format File)

Feb 21, 2008



I am using the following useful article regarding exporting a multi-record file:
http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/2007/09/25/multi-record-formated-flat-file-with-ssis.aspx

I have created the 2 datasources, ordering each on a field commmon to both.

I have created the two derived columns headers and am now moving on to the merge.

It is failing with the following error:
"the input is not sorted"

And whilst I definitely have an order by on the query, when I look at the metadata between the datasource and the derived column, the Sort Key Position items displays "0" for all my fields, I was expecting the sort field to have a "1" in this column. What am I missing?

Any help would be most appreciated!

View 7 Replies View Related

Convert Text File Format

Mar 30, 2007

Hi,
How can I convert a text file (.txt) into SQL in ASP.net 2.0 ?  The sample of the file format is like that ...
    09/03/2007 08:41 "Fung, Kitty" Granted Access D1 Main 2354 111
    09/03/2007 08:42 "Ng, Jaclyn" Granted Access D1 Main 21906 18
    09/03/2007 08:42 "Leung, Agnes" Granted Access D1 Main 21920 18
Cheers
 

View 2 Replies View Related

Wired Text File Format

Jan 24, 2007

Hi,

I have a text file contains data extracted from security logs from from different servers. The format of the data looks like this

Header row

Computer,LogFile,Type,Source,EventID,EventCode,User,Date,Time,Category,CategoryString,EventType,Description


Detail row

ServerName,Security,Audit Success,Security,540,540,DomainUserName,20061231,13:36,2,Logon/Logoff,4,Successful Network Logon:

 User Name: UserName

 Domain:  Domain

 Logon ID:  (0x0,0xD4118FE)

 Logon Type: 3

 Logon Process: Kerberos

 Authentication Package: Kerberos

 Workstation Name: 

 Logon GUID: {4bcdc9b4-4caa-ce31-b202-459f1865a477}

 Caller User Name: -

 Caller Domain: -

 Caller Logon ID: -

 Caller Process ID: -

 Transited Services: -

 Source Network Address: XX.XX.XXX.XX

 Source Port: 0

If I tries to extract data as Delimited the columns are not containing the same data for each row as there are some wired characters in the "Description" filed.

How can I extract this data as proper csv file? If not is there a way to extract only ther first line in detail row as shown below

Success,Security,540,540,DomainUserName,20061231,13:36,2,Logon/Logoff,4,Successful Network Logon:

If I tries to extract as Fixed Width, it still not work. Kindly suggest, How I can achive this.

View 4 Replies View Related

BCP And Treatment Of NULLs When Export To Fixed Format Text File

Jul 23, 2005

We are using the bcp utility (via APIs) to export data from a SQL tablein a fixed format text file. BCP is inserting spaces for a field ifthe field contains a NULL. This is fine with us except at the end ofthe line, there are no spaces for that field just the end-of-rowterminator prematurely, so it looks like that field is not present andmesses up another piece of software we pump the text file into downstream.Example -- The last row illustrates the problem.123-49-890 Mary Smith Raleigh NC
999-88-123 Henry Ax Boston MA
456-99-123 Sue Kite WA
789-88-126 Andy Yates Philadelphia
We have thought about using a SQL query to convert the NULL dataexplicitly to spaces, but were wondering is there a switch or somethingin our format file to get around this.Thanks.

View 2 Replies View Related

Exporting Data To A Comma Delimited Text File, FORMAT Function

Jan 15, 2001

Hi. Im new to SQL and I need to export a SQL table as a comma delimited text file which is straight forward. However two of the fields are integers and I need these to be right justified with zero's.
In Access I would use something like format(columnname, "00000000") to get it to work, but SQL Server doesn't like this.
How can I do this?

View 2 Replies View Related

Adapter To Convert CSV Format File To SAP IDOC Format

Nov 16, 2006

Hi All,

I am stuck at one place, where I have to convert CSV format file data into SAP IDOC format file. In SSIS we don't have any such SAP adapter (though we have .NET Data Provider for mySAP suite [SSIS SAP Adapter] but this is still not fully supported by Microsoft, plus it doesn't have feature to convert data into IDOC format) that can do this. Can someone here please provide me some pointers on any third party adapters available in market to do this job or if anyone has already developed some custom approach to achieve this task?


Your quick response on this is highly appreciated.

Regards,

Kuldeep Chauhan

View 2 Replies View Related

Getting Value From Multi-Line Text Box

Sep 28, 2004

Hi,
I have a Multiline Textbox in my application.The value from the textbox is updates in a SQL
table.The problem i have is
If I type in the textbox 1211 London street Sussex <br> UK <br>Europe ,only 1211 London street Sussex gets into the table.Anything I type after the "Enter " doesnot go into the table.

I checked the field sizes in my stored procedure and they are varchar(500) .

Any ideas

View 4 Replies View Related

SelectCommand Multi Text Boxes

Nov 7, 2007

I would like a form that has 3 text boxes. These 3 boxes are going to be used for entering search criteria. The first box is for searching a field called CasePK. The second is for searching a field called LinePK and the third is for searching a field called DOS. DOS is a date field. The other two are text fields.I am using a SQLDATASOURCE and a Gridview. What will the SelectCommand look like so that I can search the 3 fields using the data from the textboxes?

View 1 Replies View Related

Multi-formatted Text In A Single Texbox

Apr 24, 2007

The latest similar question is almost a year old and hasn't been definitively answered. I'm designing a certificate type report where the declaration text uses static and dynamic text generated in an expression for the textbox. The problem is that there doesn't seem to be an obvious way of formating sections of the text expression with different font sizes, weights and attributes to depict the effect desired. E.g. I want one textbox to say:



This Certifies that {a field value} was blah blah blah by {another field value} etc.



Can this be done in a regular textbox? If not, are there any work-arounds to accomplish the same effect. BTW, I'm working in RS 2005 flavor with VS 2005 Report Designer.



Thanks in advance for your help.

View 4 Replies View Related

How To Display The Selected Multi-value Report Parameter/s In A Text Box?

Mar 19, 2008



Hi All,

I have a report parameter which i multivalue. I want to display the selected value in a text box. I have written the following code :


=Switch(Parameters!ServiceAttribute.Count = 1,Parameters!ServiceAttribute.Value(0),

Parameters!ServiceAttribute.Count = 2,(Parameters!ServiceAttribute.Value(0) & ", " & Parameters!ServiceAttribute.Value(1)))



Which suggests that if only one of the two multivalue parameter id is selected display the same (Parameters!ServiceAttribute.Value(0)).

This works fine when i select both the attributes but throws an exception "Index was outside the bounds of the array" when i select only one of the parameters. Can anyone help me with that?

Also i want this report parameter to allow null i.e. if a user does not select anything he should still be able to view the report.
In case of regular dropdowns i have added a <Null> value to the existing values and set the default to null. But in case of multi-value, it does not give an option of adding <Null>

View 5 Replies View Related

What Is The Best Way To Combine Two Text File Into One Text File In SSIS

Mar 20, 2008



Hi,

I am looking for a way to combine two text files into one file. I am thinking of using a batch file (DOS command ) to do it. Any suggestion please?

View 6 Replies View Related

Is It Possible To Format (Text) In This Way

Jun 14, 2007

hi,



i want to display something is this fashion



Roth 401(k) Contribution

jfkajfkdjfdjfkdj ldkfdlkfl;dkfldkfld;fkdl



in a table row, but i am not sure how to do it. can some one pls give me some ideas.



Regards,

Karen

View 5 Replies View Related

Is It Possible To Write A Format File That Skips A Few Bytes Of Header In Data File?

Jul 23, 2005

Hi,I am trying to use BULK INSERT with format file. All of our data hasfew bytes of header in the data file which I would like to skip beforedoing BULK INSERT.Is it possible to write format file to skip these few bytes ofheader before doing BULK INSERT? For example, I have a 1 GB data filewith 1000 byte header. Except for first 1000 bytes, rest of the data isgood for BULK INSERT.Thanks in advance. Sorry if it is really a dumb question as I am newto BULK INSERT and practicing still.Bob

View 7 Replies View Related

Analyse File Format By File Flat Connection

Jan 16, 2008

I have a txt file with format as following

MailAddress:Kienpt@ifi.local
DomainName:ETH2K

[Date]2007/12/27 15:02:50 [Operation]
[Date]2007/12/27 15:02:50 [Operation]
[Date]2007/12/27 15:02:50 [Operation]


I want to use File Flat Connection to analyse format of this file. And i want each record after analysing include 4 fields as folowing:

- MailAddress, DomainName, Date, Operation
(Mail Address and DomainName is same in each record)

Can you help me?

View 1 Replies View Related

Error Msg 6522, Level 16, State 1 Receives When Call The Assembly From Store Procedure To Create A Text File And To Write Text

Jun 21, 2006

Hi,
I want to create a text file and write to text it by calling its assembly from Stored Procedure. Full Detail is given below

I write a code in class to create a text file and write text in it.
1) I creat a class in Visual Basic.Net 2005, whose code is given below:
Imports System
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Diagnostics
Public Class WLog
Public Shared Sub LogToTextFile(ByVal LogName As String, ByVal newMessage As String)
Dim w As StreamWriter = File.AppendText(LogName)
LogIt(newMessage, w)
w.Close()
End Sub
Public Shared Sub LogIt(ByVal logMessage As String, ByVal wr As StreamWriter)
wr.Write(ControlChars.CrLf & "Log Entry:")
wr.WriteLine("(0) {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString())
wr.WriteLine(" :")
wr.WriteLine(" :{0}", logMessage)
wr.WriteLine("---------------------------")
wr.Flush()
End Sub
Public Shared Sub LotToEventLog(ByVal errorMessage As String)
Dim log As System.Diagnostics.EventLog = New System.Diagnostics.EventLog
log.Source = "My Application"
log.WriteEntry(errorMessage)
End Sub
End Class

2) Make & register its assembly, in SQL Server 2005.
3)Create Stored Procedure as given below:

CREATE PROCEDURE dbo.SP_LogTextFile
(
@LogName nvarchar(255), @NewMessage nvarchar(255)
)
AS EXTERNAL NAME
[asmLog].[WriteLog.WLog].[LogToTextFile]

4) When i execute this stored procedure as
Execute SP_LogTextFile 'C:Test.txt','Message1'

5) Then i got the following error
Msg 6522, Level 16, State 1, Procedure SP_LogTextFile, Line 0
A .NET Framework error occurred during execution of user defined routine or aggregate 'SP_LogTextFile':
System.UnauthorizedAccessException: Access to the path 'C:Test.txt' is denied.
System.UnauthorizedAccessException:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, ileOptions options)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path, Boolean append)
at System.IO.File.AppendText(String path)
at WriteLog.WLog.LogToTextFile(String LogName, String newMessage)

View 13 Replies View Related

Store Xml Output In Text Format

Jun 4, 2008

I have the following Query which gives the output in XML format.
select * from <Table_Name> For XML auto
I wanted to store this output in a .Xml file at my local machine.
I would prefer to have a proc when called generates the xml and stores it on the local m/c. Any ideas ?
Thanks,

View 3 Replies View Related

Dependency Tree In Text Format?

Mar 7, 2000

Hi,

I have a database of over 200 tables. I want to delete data in about 100 tables. It's hard for me to delete because there are so many dependencies. I wind up tracing each table until I find the end and then deleting backwards. Is there a script I can run where I can get a textual view of which tables are related to which tables (foreign key constraints). I don't want to hit 'display dependencies' on each table. I know I can look at logical diagram but with a database of over 200 tables, it is hard to look at it.

Thanks,
Angel

View 4 Replies View Related

Change-Format Text To Date

Jun 12, 2008

I have a column of text 010208 that is suppose to be a date. How can I changeformat this column to read 01/02/2008?

Lisa Jefferson

View 9 Replies View Related

Create Trigger To Format Text

Mar 4, 2015

We are using an old version of Numara TrackIT for our helpdesk software, and it doesn't have much in the way of configurable options. There is no way to set validation or formatting on the text fields in the program.

There is a field, WO_TEXT1, Which I would like to be formatted as 6 characters, 3 integers + a period + 2 integers. The first the integers would be padded with zeros on the left, and the last 2 integers would be padded with zeros on the right.

IE, if someone enters 2, it would actually end up being 002.00
If someone enters 3.5 it would end up being 003.50
If someone enters 12.1 it would end up being 012.10
If someone enters 172.80 it would end up being 172.80

I was hoping to achieve this via an update trigger.

Below is the guts of the trigger I created, mostly as a proof of concept.

-- This update properly formats the Estimated Hours field
Update t SET WO_TEXT1 = (SELECT RIGHT('000000' + CONVERT(VARCHAR(6), WO_TEXT1), 6) FROM inserted)
FROM dbo.TASKS as t
Where (EXISTS (SELECT * FROM inserted WHERE WOID = 24773));

I expected that this update trigger would only affect the Work Order with a WOID of 24773. Unfortunately, it updated all 21000 work orders in our system, wiping out all of the actual estimated hours that had been inserted by technicians!

Luckily I had a report that I could quick dump the 300 or so active work order's estimated hours back into the DB from (all the other Work orders are closed, and no one really cares about their estimated hours).

My question is three fold,

1) Why did my trigger update every record in the tasks table instead of just WO 24773?
2) Is using a trigger the best way of accomplishing what I'm trying to do?
3) if a trigger is the best way of accomplishing this, what should my trigger look like?

View 12 Replies View Related

Format Text Box With Parentheses If Negative

May 24, 2007

The users want to see negative values like this:



(-$1,000)



How do I format negative values that way without some major iif statement?

View 6 Replies View Related

How To Get Report In Text Format In SSRS?

Sep 3, 2007

Hi,

Can aybody help me in the below requirement.

I have a report like below:





<<Name Of Compnay>>
<<Name Of Report>>

<<Todays Date>>
<<ReportPeriod>> From Date - To date

The above is header and then the data in the report should come as the <<Data>> and # to be used as separator for columns.

163 #GXXX #ABC Comp Ltd. #DTDC#PPPP ABC XYZ ETC #111







*End Of Report*

How can I get this exported as it is to the .txt file?

Currently I have acheived this with SSIS, where I have kept the header template, footer template in my folder. The SSIS generates the .txt file and then I use the execute process transformation to merge the files and data. I am getting the exact o/p as I want. But in this I am intorducing lot of IO in the package by every time creating a new header for the data to be replaced as todays date and the period to be replaced by the user selected Report Period.

How can this be achived using SSRS? Is any custome code required?
Thanks in advacne for your help.


Regards,
Virendra





View 19 Replies View Related

Update Multi File

Aug 24, 2007

Hi,
I have the following case:-

File a(transaction File)__File b(summary File)___File c(summary)
acctno___Value DB/CR_____Acctno DB,CR_______acctno DB,CR
1___________100db___________1______________________1
1___________300cr___________2______________________2
1___________600db
2___________700db

I want to update the account on table b and c from table a.

My current update is just for one table as follows:-
UPDATE amaster
SET cmdb = cmdb +
(SELECT SUM(transact.damt) AS Expr1
FROM transact
WHERE (acctno = amaster.acctno)
GROUP BY acctno),
cmcr = cmcr +
(SELECT SUM(transact.camt) AS Expr1
FROM transact
WHERE (acctno = amaster.acctno)
GROUP BY acctno)
FROM amaster INNER JOIN
transact ON transact.acctno = amaster.acctno



thanks

View 1 Replies View Related

Convert Text Data To Date Format

Nov 13, 2013

I've got a field I'm trying to convert into a date format as it currently sits as a text field. The date setup is of the format DD/MM/YYYY. Some of the fields are NULL, however for the sake of filling in gaps I've just set the nulls to '01-01-1905'.

I've tried to use CAST to change the data into a readable format for SQL Server however I tend to get one of two messages:

Conversion failed when converting date and/or time from character string.

-Or-

error converting data type varchar to date

View 2 Replies View Related

Encrypt And Decrypt Text Format Data

Oct 19, 2007

Hi,

We have migrated a CRM Database from SQLServer 2000 to SQLServer 2005.



Database contains very sensitive data about customer in text format (Datatype varchar(20)) how can i encrypt the same without any change in the table design.



Regards
Sufian


View 6 Replies View Related

Query String Field Based On Text Format

Mar 7, 2008

I need to search a nvarchar field based on the format of the text.  This field holds values in two formats: 000 000 000 000 and 000000.   I only want to search through the records that are in the 000 000 000 000 format.  Can anyone give me direction on how to go about doing this or give me some key words to search for on Google?  Fixing this problem is not an option.  This is a county tax DB from a poor county with almost a million records in it. 
 Thanks for the help!

View 2 Replies View Related

Keeping Text Format After Stored In The Data Base.

Jan 14, 2004

I want the users of my site to be able to write a couple of paragraphs, save it to SQL Server and then have it read back and look the same. I don't want the users to be able to add any html to the text they submit. I just want them to be able to seperate or indent their paragraphs.

At one point, I had a textbox that saved text to the server and read it back the same way it was originally inputed. However, I can't figure our what I had done to make it work.

Any ideas?
Thanks

View 2 Replies View Related

SQL 2012 :: Date Format In Text Column With Many Other Inputs

Feb 10, 2014

How to convert MM/YYYY to MM/DD/YYYY and also YYYY to 01/01/YYYY.

This column is text column and has many other inputs.

View 4 Replies View Related

SQL 2012 :: Select And Format A Text In A Varchar Column

May 9, 2014

One purchased app stored user's multiple lines input into a varchar column in which including char(13) and char(10).

My app need to select this value and format to multiple lines text in one text box.

How to code to output it?

View 5 Replies View Related

How To Align The Text In Justify Format With SQL Server Reporting Services?

Jan 18, 2007



How to align the text in justify format In SQL server Reporting Services? Is there any code to do so?

View 29 Replies View Related

SSIS File Watcher Multi-Threaded Task?

Jan 28, 2007

Hi All,

I have a problem in which I want the run an SSIS based on a file being dropped in a directory. I've tried the WMI event watcher as well as the File Task Watcher component. The problem that I'm seeing is that if the process is currently processing in the pipeline while another file dropped, the newly dropped file doesn't get picked up. Is there a way to create a FileWatcher Task in SSIS which will spawn a SSIS job and return immediately for watching files?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved