DTS- Add Global Varible's Value To Text File

Sep 7, 2005

Hi, I have a DTS which has a connection, 3 destination text files and a
Process execution job which runs a simple batch file to concatenate
this 3 files into a 4th text file "Endeud.txt". I added an activeX
command Job to input a date which is saved in a global variable. I
need to add this date at the end of the Endeud.txt file (The date would
be the last line of Endeud.txt. How can I do this?

View 1 Replies


ADVERTISEMENT

Problem With Like @varible%!

Dec 20, 2007

Hi,

I'm trying to create a page in a web browser where users can type the name of a company in a text box and to get details of the company. I can hard code like the below example and it brings up the details i'm looking for.


The problem is when I try to replicated this with a stored procedure it doesn't work.

Thanks for any help in advance,



Code:

select * from company
where companyname like 'companyx%'






Code:

procedure company_detail_search

(@company nvarchar)

as

select * from company
where company @comapany%

View 2 Replies View Related

Varible Passing

Apr 26, 2006

Hi:

When i try to execute the following stmt using sqlcmd, it is giving me error.

c:>sqlcmd -i "c:sqlconfigDDLLogging.sql" -v LogDir='c:sctclogs'

the error is
Sqlcmd: ':sctclogs'': Invalid argument. Enter '-?' for help.

but when i pass just -v LogDir='csctclogs' it work fine.

The problem is with ":" when i put colon it throws error.

Any help to execute the above command would great.

Thanking you,

Best regards,

Kumar

View 9 Replies View Related

Drop A Database When The Name Is Supplied As A Varible

Jan 17, 2008



I have created a stored procedure that will back up a database to a file then restore the database into a new db. The stored procedure accepts 2 parameters that determine the name of the old DB to be backed up and the name of the new DB to be created. The only problem now is that when you specify the name of a database that already eixists, the restore fails. I want to add an if statement that would check to see if the new db supplied exists, and if it does drop it before running the restore.

I thought the following would work but it does not




Code Block
declare @DB nvarchar (50)
set @DB = 'LDRPSsmap2k'

IF EXISTS (SELECT name FROM sys.databases WHERE name = @db)
Drop Database @db


I get When i run this

Msg 102, Level 15, State 1, Line 7

Incorrect syntax near '@db'.

View 3 Replies View Related

Error While Assigning Value To The Varible In Execute SQL Task

Jun 21, 2007

Hi,

In Execute SQL Task, I'm facing following error when Result Set assigns value to the global variable.

SSIS package "Package.dtsx" starting.Error: 0xC002F309 at Execute SQL Task, Execute SQL Task: An error occurred while assigning a value to variable "IDCount": "Value does not fall within the expected range.".Task failed: Execute SQL TaskWarning: 0x80019002 at Package: The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.SSIS package "Package.dtsx" finished: Failure.

My SQL statement is "Select count(*) as AliasNm from <TableName>" and my Result Set type is Single Row.

I mentioned in the Result Set's Result Name as AliasNm.

Help me to resolve this error.

Thanks in advance.

Suku

View 17 Replies View Related

Storage Location For A Configuration File For Global Variables In DTS

Nov 15, 2007

Hello,

We have an existing OLD System in SQL Server 2000 DTS Packages.
The Whole application runs on DTS.
There are several Packages which are called from a Master Package. Each Child packages have their own Global Variables. Most of them are the File Location variables to have the Source Location of the Input Data, mainly from the Excel Files.
Now, even if the Global Variables are there to change whenever they want to change the Locations of the Files, they have to goto each child package and change the variable themselves.
To resolve this issue, they want a configuration File (INI) / Table which would store those Variables. My thought is to read from that File/Table and Update all the packages' global variables through an ActiveX Script as the First Step of the Master package. That would eliminate the need of changing anything in the existing System.
But the Problem is the management (PM / DBAs / Team members) have different views to store the Configuration data.
1. Some wants it into a Different Database, having one table for this application so in future they can also add another table for some other application.
2. Some wants to store it in a Table in the Same Database of this Application.
3. Some wants to save it as a INI file.

As i'm the one who's going to really implement it, they have asked me to research for a best solution out there.

so I request to help me to decide which is a good solution and why.

Best Regards,
Deepak

View 4 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

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

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

Export Stored Procedure To Flat File And Add Aggregate To End Of The Text File?

Jan 31, 2008

What is the easiest way to accomplish this task with SSIS?

Basically I have a stored procedure that unions multiple queries between databases. I need to be able to export this to a text file on a daily basis and add a total records: row to the end of the text file.

Thanks in advance for any help.

View 7 Replies View Related

Read Text File From Flat File Connection Manager SSIS

May 13, 2008

Hello Experts,
I am createing one task (user control) in SSIS. I have property grid in my GUI and 2 buttons (OK & Cancle).
PropertyGrid has Properties like SourceConnection, OutputConnection etc....right now I am able to populate Connections in list box next to Source and Output Property.

Now my question to you guys is depending on Source Connection it should read that text file associated with connection manager. After validation it should pick header (first line of text file bases on record type) and write it into new file when task is executed. I have following code for your reference. Please let me know I am going in right direction or not..
What should go here ?
->Under Class A

public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)

{

//Some code to read file and write it into new file

return DTSExecResult.Success;

}


public const string Property_Task = "CustomErrorControl";

public const string Property_SourceConnection = "SourceConnection";



public void LoadFromXML(XmlElement node, IDTSInfoEvents infoEvents)

{

if (node.Name != Property_Task)

{

throw new Exception(String.Format("Invalid task element '{0}' in LoadFromXML.", node.Name));

}

else

{

try

{



_sourceConnectionId = node.Attributes.GetNamedItem(Property_SourceConnection).Value;



}

catch (Exception ex)

{

infoEvents.FireError(0, "LoadFromXML", ex.Message, "", 0);

}

}

}

public void SaveToXML(XmlDocument doc, IDTSInfoEvents infoEvents)

{

try

{

// // Create Task Element

XmlElement taskElement = doc.CreateElement("", Property_Task, "");

doc.AppendChild(taskElement);

// // Save source FileConnection

XmlAttribute sourcefileAttribute = doc.CreateAttribute(Property_SourceConnection);

sourcefileAttribute.Value = _sourceConnectionId;

taskElement.Attributes.Append(sourcefileAttribute);

}

catch (Exception ex)

{

infoEvents.FireError(0, "SaveXML", ex.Message, "", 0);

}

}

In UI Class there is OK Click event.

private void btnOK_Click(object sender, EventArgs e)

{

try

{



_taskHost.Properties[CustomErrorControl.Property_SourceConnection].SetValue(_taskHost, propertyGrid1.Text);

btnOK.DialogResult = DialogResult.OK;

}

catch (Exception ex)

{

Console.WriteLine(ex);

}

#endregion

}

View 10 Replies View Related

How Can Unzip File Text File Using SSIS

Oct 1, 2006



Hi,

I am pulling text files in gzip format from UNIX system. I want to unzip these files and then import data from these files into database using SSIS.

View 15 Replies View Related

Inserting Data To Text File From Database And Inserting Data Back To Database From Text File

Aug 7, 2007

Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.

View 10 Replies View Related

SQL To Text File

Dec 31, 2001

Is it possible to export a sql table to a text file without using DTS? And also can we put a header on it


Thanks

View 1 Replies View Related

SQL To Text File

Jan 2, 2002

Can we insert a header if we export the sql table thru DTS or BCP


Thanks

View 4 Replies View Related

Text File

Jan 2, 2002

how can we insert the header.
Here's my problem :
I have to export a table form SQL to a text file But I want to have a line "XXXXXXX" as the top most line of the text file.
Can this be achieved thru DTS or BCP

View 1 Replies View Related

Text File

Nov 6, 2000

I would like to send the data content in a table to a text file. Is there a stored procedure command to do that? Any help would be greatly appreciate. Thanks in advance.

View 1 Replies View Related

Export To A Text File, Then Name The Exported File The Date Is Was Exported, Then Zip

Jul 3, 2007



Hi folks



Any help on my request would greatly be appreciated. We are trying to maintain the growth of a particular table, by exporting and deleting data that is older then 90 days. Here are the 4 steps I need to do. I believe I know how to do 1 and 4;

1. Create a job that continously exports data that is older then 90 days to a text file

select *

from table A

WHERE (CREATED < DATEADD(DAY, - 90, GETDATE()))



(the column 'created' datatype is datetime and looks like this '3/5/2007 3:11:44 PM')



2. Have the job automatically name the exported file, the day it was exported (i.e. 07032007 (todays date))

3. Then zip that file (we're using 7-zip)

4. Then delete the data out of the table

delete

from table A

WHERE (CREATED < DATEADD(DAY, - 90, GETDATE()))



Im not a big scripter/coder, so I was wondering if there is anything I could do in SSIS. Im more familiar with DTS, so any kind of baby steps you could provide in SSIS, would go a long way.



Thank you so much.

View 1 Replies View Related

Output To A Text File

Sep 3, 2006

Is it possible to send the output of a query to a text file in a stored procedure? When I run stored procedure in Query Analyzer I am able to do that and I am wondering if this is possible in a automated way?

View 2 Replies View Related

MSSQL To Text File?? How?? Thanks...

Dec 26, 2006

As we know, MySQL have function to output its data into Text File using "Select * into outfile 'C:/mytext.txt".
Does MSSQL has "Select into Outfile" function??? If yes, what is the function??
Thanks in advance  :)
 Anderson

View 4 Replies View Related

Reading In A Text File

Sep 25, 2007

I need to know how to import a text file into a stored procedure as one big varchar.  I don’t want to import the data straight into my tables.  I need to be able to work with it in the stored proc.

View 2 Replies View Related

Importing Text File To Sql

May 1, 2008

Happy Thursday all,
I am importing a text file to sql and most of my fields look like this:
"M","NEW ADDRESS",
and my other field looks like this:
"firstname Lastname"
but I need it like this:
"firstname", "Lastname"
Can anyone help me understand a better way of making this happen?
 
Thanks in advance

View 2 Replies View Related

Generating Text File

Dec 4, 2003

I have a table(say tblUserInfo) on SQL Server. What I like to do is a text file will be generated on the hard drive which SQL Server sits on when a new record is inserted into tblUserInfo. The content of the text file comes from the table. Is there any way we can go for doing that?

View 2 Replies View Related

How To Make A Text File

Dec 10, 2003

I have a table(tblUser) on SQL Server. I like to create a text file somewhere on the SQL Server after a new record is inserted into the table(tblUser). The content of the text file should be the new record. Is there any way to do that?

Thanks!

Regards,

Kevin Jin

View 1 Replies View Related

DTS Text File To SQL Table

Apr 6, 2004

Hello,

I have an access database (access 95 Version7)dumping a delimited text file onto my server. I am then using DTS in SQL 2000 to import the file into a table.

My issue is that each time the DTS runs, it imports the whole text file each time, this is causing duplicate records.

So I created a transformation script as follows :

Function Main()

If DTSSource("counter") <= DTSDestination("counter") Then
Main = DTSTransformStat_SkipRow
Else

DTSDestination("counter") = DTSSource("counter")
DTSDestination("serialdata") = DTSSource("serialdata")
DTSDestination("serialdata1") = DTSSource("serialdata1")
DTSDestination("date") = DTSSource("date")
DTSDestination("time") = DTSSource("time")
Main = DTSTransformStat_OK

End If
End Function


The theory behind the If statement, is if it sees that the counter field is less than or equal to what is there, it will skip the record and move forward. For some reason this is not working.

Does anyone have a workaround or another solution to this problem

View 3 Replies View Related

Importing Text File To SQL

Sep 15, 2004

HI Guys,

I am doing the following to read the data in a text file and inserting it into SQL.

1) Open db connection
2) Open Text File
3) loop through text file all along inserting each row into the db
4) close the text file
5) close the db connection

However, the text file has over 400 rows/lines of data that need to be inserted into the db. Each line in the text file is a row in the db. At anyrate, the above script times out. Is there a better, faster way to do this? I can't use Bulk Insert due to permissions previlages.

Thanks in Advance!

View 2 Replies View Related

Text File Import

Apr 17, 2000

SQLServer 7.0

Hi,

I have a small project on that involves importing a series of csv files held within an ftp directory into our Datawarehouse. Every day a series of csv files will be added to the directory. These will be named something like:

Audit1.csv,Audit2.csv etc.

I would like to automate this process as this can involve up to 400 files at a time. The proecedure would need to identify a valid file, import it into the database, delete the file and then move onto the next one.

Does anyone know of a way to achieve this? I was thinking along the lines of using a cursor and bcp but I'm not sure how to identify these files to the database i.e. how do i make it step through the directory and process the files?

Any help would be greatly appreciated.

Thanks

Rob

View 1 Replies View Related

DTS Import Text File

Oct 20, 1999

In a DTS package I have a text file import object, a data pump, and a SQL object. The text file import object has been set up to splice a 500 character wide file into 20 columns. The data pump task does a copy column for all the columns into the appropriate table. What I need to do is have a way of changing the file name I specify in the text import object. I have 12 months worth of data in seperate files (DBF0199.TXT, DBF0299.TXT, DBF0399.TXT, etc..)
which all use the same format. Is there a way to change the text import objects file name inside the package using an active script task or something?

Any help is greatly appreciated.

Thanks,

Todd

View 4 Replies View Related

Write To Text File

Mar 8, 2001

I am using bcp to write from a query or table into a text file from a stored procedure. No problem. However, what do I do if I want to write to a text file from another stored procedure which returns a record set? Any help gratefully received. thanks.

View 1 Replies View Related

INSERT INTO Text File

Nov 18, 2002

I am trying to SELECT various fields from a table in SQL Server to INSERT INTO a Text file defined using a Schema.ini. I know that this can be done using BCP (not sure if I could specify which fields as not all are required), DTS (which I have done) and with a Linked Server (where I keep getting a bookmark error). The process used in Access is [Sample#csv] IN 'C:' 'TEXT;' but I can't seem to find the format to use in SQL using either a MSDASQL or ODBC connection string. Any ideas would be greatly appreciated, thanks.

View 1 Replies View Related

Using DTS To Import Text File

Dec 5, 2002

I'm trying to import a fixed field text file into SQL Server using DTS but everytime I go past 3640 characters, I am not able to add, delete or move column breaks after that. Is anyone else experiencing this problem and know of a work around. Any help would be appreciated. Thanks!

Using SP2 on SQL Server 2000.

View 3 Replies View Related

DTS Into Text File Error

Aug 19, 2003

Hi there,

I getting really frustrated here when trying to export a table with many columns into a text file. This does not happen when the table is relatively small.
I am using client tools on my machine connecting into SQL Server 2000 (sp3) that resides on a different box.
I have installed the client tools on my machine from scratch; no SQL server components were on it before. The version in the Add/Remove Program for SQL Server 2000 showed 8.00.194.
Then I have upgraded my machine (Not the server) client tools into sp3a (sp3a). The version in the Add/Remove Program for SQL Server 2000 shows 8.00.761.

Now, the problem is when I try to create a package that export data into a text file and the source is a table or a view with many columns, even only 18 columns. Trying to define the column structure in the destination file using "Define columns" button on the Destination tab, I get error message
"The instruction at "0x780014b1" referenced memory at "0x00000000". The memory could not be "read". and Enterprise Manager fails. This did not happened when I had version 194 before. only after installing sp3a. when I try to open a package that has been created in 194 version I can see the column definition of the destination, but again, it fails when I try to change it by "Populate from source" and "Execute".
Also, I can't change the column size on the "Define columns" window (for fixed length destination), but I could do it on 194 version.

So:
1. How come the newer version is worse than the previous one ? I know that Microsoft has solved some problems relating to this issues (some MDAC changes and more).
2.What can I do to solve this problem. Do I have to have other version ?

Any help will be appreciated.
[B]

View 1 Replies View Related

Import Text File

Sep 14, 2004

Is it possible to handle text files i MS SQL 2000 in which fields contains single quotations and also are terminated by a single quotation

Like this:
1,2,'John's',1,2

John's contain a single quotation

Or is possible to rewrite file using MS SQL to use double quotation
Like this;
1,2,"John's",1,2

Hope that someone can help me out here, and doing it using MS SQL

At the time, I'm handlig it using MySql, but I would prefer using MS SQL

Regards
Carsten H.

View 4 Replies View Related







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