Showing posts with label format. Show all posts
Showing posts with label format. Show all posts

Thursday, March 29, 2012

DTS file name to include System Date/Time

We have an application group that wants to pull date from SQL Server and write it to text file on the server. They want the file format to be 12100_YYYMMDDHHMM.fr1 for one set of data, 12100_YYYMMDDHHMM.fr2 for a second set...and so on. The '12100' is fixed, but the rest of the file name will always have to include the system date/time. Is there an easy way to do this within a DTS package (when writing to the output file)?

I would really appreciate help on this. Thank you.Hi

You can set a global variable to the fixed part at the start of the process. This should help http://www.sqldts.com/default.aspx?200 although you want to set a global variable rather than a local one.

John
"steven virnig" <pezguy@.mn.rr.com> wrote in message news:o1ovd.114089$ye4.34831@.twister.rdc-kc.rr.com...
We have an application group that wants to pull date from SQL Server and write it to text file on the server. They want the file format to be 12100_YYYMMDDHHMM.fr1 for one set of data, 12100_YYYMMDDHHMM.fr2 for a second set...and so on. The '12100' is fixed, but the rest of the file name will always have to include the system date/time. Is there an easy way to do this within a DTS package (when writing to the output file)?

I would really appreciate help on this. Thank you.

Tuesday, March 27, 2012

DTS Export to Excel (How to Format Results in Excel)

Hi All

I've been googling this for a while now and can't seem to find any elegant answers.

I'm looking for an automated way to present a FORMATED Excel Spreadsheet to the Customer from a stored procedure output.

Can anyone advise me the best method of doing this - should I / can I assign an Excel Template to the DTS Task output ?

His mind is set on Excel and the formatting is basic and easy to write in a Macro which I've done, but this requires human interaction to finish the task (Automated Run Once on opening etc).

In an ideal world an individual would send an email to the Server with two formated parameters (@.FromDate & @.ToDate) and would be emailed back a ready formatted S/Sheet. But I believe he would be willing to just select the relevant SpreadSheet for the Daily / Weekly / Monthly periods dumped.

Thanks

GWTurn your logic inside out. Create the macro, and use the macro to retrieve the data into Excel then format it.

-PatP|||Thanks for the suggestion Pat

I eventually got MSQuery installed & got some simple External Data into a sheet in Excel - Formatted another sheet and the past linked the Data from source sheet to the new sheet which seemed to work really good.

Then I tried altering the External Data Call to include the @.FromDate & @.ToDate.

O worlds of pain - got as far as this err :-

[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

There's no cast/convert in the SP so I assume it's the dreaded ODBC Driver again.

O why O Why did you guys insist on formatting your dates funny m/d/y instead of the correct way which is British English d/m/y (Flame Flame - tehe) which I assume maybe the problem.

I'll battle on - any suggestions gratefuly received.

GW

DTS Export format, please help

I have a table (tblstudent) with four fields, Fname, Lname, City, Zip.
I want to run a DTS export nightly that export the records out to a file.
The kick is that I would like the text file to list the fields on their own
line like:
Fname
Lname
City
Zip
Instead of across like: Fname, Lname, City, Zip.
How can I accomplish this?
Thanks for your time!
TonyHopefully this will solve your issue. write the code in Axtivex script in DT
S.
========================================
=========
'***************************************
*********************
' Visual Basic ActiveX Script
'***************************************
*********************
Function Main()
Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "sqloledb"
Conn.Properties("Data Source").Value = "(local)"
Conn.Properties("Initial Catalog").Value = "Testing"
Conn.Properties("Integrated Security").Value = "SSPI"
Conn.CommandTimeout = 0
Conn.Open
'--get students record set
SqlQuery ="select * from tblStudent"
Set RsStudent = Conn.Execute(SQLQuery)
'--ourt vars
ourputString = ""
Path = "C:\test\"
'-- create output folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(path) Then
objFSO.CreateFolder (path)
End If
'--Create Traget file
Set TargetFile = objFSO.CreateTextFile(Path &"Report.txt", True)
IF not RsStudent.eof Then
While not RsStudent.eof
ourputString=""
ourputString="Fisrt Name: " & RsStudent("FName") & vbcrlf & _
"Last Name:" & RsStudent("Lname") & vbcrlf & _
"City :" & RsStudent("City") & vbcrlf & _
"Zip :" & RsStudent("Zip") & vbcrlf & _
"----
--" & vbcrlf
TargetFile.WriteLine(ourputString)
RsStudent.moveNext
Wend
End If
Set TargetFile=Nothing
Set objFSO=Nothing
Set RsList =Nothing
Conn.close
set conn = nothing
Main = DTSTaskExecResult_Success
End Function
========================================
=========
"tony tuso" wrote:

> I have a table (tblstudent) with four fields, Fname, Lname, City, Zip.
> I want to run a DTS export nightly that export the records out to a file.
> The kick is that I would like the text file to list the fields on their ow
n
> line like:
> Fname
> Lname
> City
> Zip
> Instead of across like: Fname, Lname, City, Zip.
> How can I accomplish this?
> Thanks for your time!
> Tony
>
>

Monday, March 19, 2012

DTS And VBScript

I have an application written in C#, which allows the user to load their destination schema (in xml format) and writer their transformation expressions either in VBScript or in T-SQL. It uses DTS to do the ETL job.

Everything works great except with one problem. If there is a hypen ("-") in any of the destination attributes, the transformation fails with syntax error. It happens only with VBScript.

Here is my transformation:

"Function Main()

DTSDestination(\"Field-1\") = #01/01/2004#

End Function"

If I replace the hypen with underscore, it works without any problem.

Does anyone have any idea about this problem?Did you try to put the field name between brackets?
[field-1]|||Tried with \"[Field-1]\" and it did not do the magic|||Perhaps a hyphen is an invalid character for a field name. Use underscores and your problem is solved. You shouldn't be using '-'s in field names, anyway.|||In general hypen ('-'s) are not allowed in a field. But if you enclose in [], it is a valid chr (atleast in SQLServer!).

As my application is a B2B application and schema is maintained by an organization, I don't have any control. Hence I can not modify the field name.

BTW, I tried the same this with Enterprise Manager, it works.

DTS and macro excel

hi,
I have already set up a DTS package to convert my data to an excel file and I would like to alter the format of my data through my DTS without having to write a macro.
Do you know how to do this?need more details.|||From the DTS I get a plain text in my excel sheet. I have written a macro that takes all the sheets in the workbook and converts the first line of every sheet. The formating is to put a background color to and just make the cells and bit bigger.

Thanks a lot

DTS and Fixed Widths

Hi all.

I'm trying to export some tables in fixed width format for a client that needs it this way. The first time I did this, using Import/Export in Enterprise Manager, integer fields were 12 chars long. However, when I saved this as a DTS and ran it again later, it made integers 4 chars in the text file (which matches the lengths of the datatypes you see in enterprise manager.)

Why is this difference there? What do I need to do differently? Also, is there a list of how wide each data type is when exported as fixed delimited text?

thanks,
CraigWell, I just followed the same steps and received consistent results. My integer files were 12 characters with the initial run, and also when I saved it as a DTS package and ran it.

My suggestion is to check the Transform Data Task Properties in the DTS package and check the information in the Size column on the Destination tab for each column.

When you create the package via the Import/Export option in Enterprise Manager, one of the steps includes a "Transform..." button. Click on this so you can explictly set the size of each column you are exporting.

Terri|||yes I found it. There is a "Define Columns" button that specifies the size. Weird that the same DTS package yielded multiple results.

Thanks!

DTS and Fixed Widths

Hi all.

I'm trying to export some tables in fixed width format for a client that needs it this way. The first time I did this, using Import/Export in Enterprise Manager, integer fields were 12 chars long. However, when I saved this as a DTS and ran it again later, it made integers 4 chars in the text file (which matches the lengths of the datatypes you see in enterprise manager.)

Why is this difference there? What do I need to do differently? Also, is there a list of how wide each data type is when exported as fixed delimited text?

thanks,
CraigWhy don't you use bcp in a sproc with format files?

And as far as DTS changing widths...I don't think (damn it, happened again) so...|||I assume you're talking about Bulk Copy? I haven't done that before, but its definitely an option -- I just ASSUMED DTS would be easier.

Friday, March 9, 2012

DTS : Format Problem !

I have a statement in the DTS ( Activex Script ) like this :

TomorrowDate = Format$(Now, "yyyy-mm-dd")

When i am running the package, i am getting the following error :


ActiveX Script Task: undefined

Error Code: 0

Error Source= Microsoft VBScript compilation error

Error Description: Invalid character

Error on Line 8

Can anyone tell me what is the solution to this error ?

Thanks in advance.

Remove the $ in Format$

-Vijay

|||

Hi vijay,

Thanks. Even when i removed $ from format, still an error :

Telling that :

Type Mismatch "Format"

Sunday, February 26, 2012

DTS

Hi,

What is good way of executing .dtsx jobs in sql 2005, when stored in file format, or msdb database. Can my sql agent read jobs from file format as well as msdb database ?

Thanks &Regards

Nitu

Yes SQLAgent can execute file system or msdb packages. I'm surprised you could not find that information in Books Online. The online version is here ...

http://msdn2.microsoft.com/en-us/library/ms141701(SQL.90).aspx

At the bottom of every Books Online page there is an option to vote for the usefulness of the content. You can do that to help us improve the content - I'm concerned that you are not finding this information there, so any help you can give us would be appreciated.

Donald Farmer

Friday, February 24, 2012

DtPicker Format

i have placed one date picker in a Vb form,while i select the value from datepicker the selected value is assigned to a textbox,while selection it is selecting in proper date format but my backend is SQL 2000,in backend it is storing the date as 1/1/1900 .00.00.00 ,so can help why this happens and send me the correct coding for that .

what i found out is while i select date between eg: 1/1/00 to 12/1/00 it will store in a correct format in backend,but if select 13/1/00 it won't store,i think it is taking in yyyy-dd-mm,i had given coding like this
insert into (regdate) values(' " & format(text1.text,"dd/mm/yy") & " ')"

can u help me for this by sending correct coding

thanks

saiju

saijumammen@.gmail.comTry this format

insert into (regdate) values(' " & format(text1.text,"dd-mmm-yyyy") & " ')"|||Dear Saiju
I had this problem , the best way to beat this is to change the date to "dd MMM yyyy" format and store it , Believe me it works

chk = format (dtpicker1.value,"dd MMM yyyy")
This is in a string format
Project it to the insert statement as a string and it works
This is to compliment what madhi has said|||Thank u ,Madhi & Rambi for the assistance for my Datepicker Problem.

This really helped me

Thanks once again

Saiju Mammen

Sunday, February 19, 2012

DTC question

Hi friends,
If I have a ms dtc log file on my hands, and it is, I believe, in some
binary format, is there any way to view it?
Thanks a lot in advanceHi,
> If I have a ms dtc log file on my hands, and it is, I believe, in some
> binary format, is there any way to view it?
I'm afraid there is no way to do it. The file is encrypted as an
internal part of DTC service.
Best regards,
Marcin Guzowski
http://guzowski.info|||It is sad.
It's actually dtc trace file.
"Marcin A. Guzowski" <tu_wstaw_moje_imie@.guzowski.info> wrote in message
news:esu87d$p2a$1@.news.onet.pl...
> Hi,
>> If I have a ms dtc log file on my hands, and it is, I believe, in some
>> binary format, is there any way to view it?
> I'm afraid there is no way to do it. The file is encrypted as an internal
> part of DTC service.
>
> --
> Best regards,
> Marcin Guzowski
> http://guzowski.info

DTC question

Hi friends,
If I have a ms dtc log file on my hands, and it is, I believe, in some
binary format, is there any way to view it?
Thanks a lot in advance
It is sad.
It's actually dtc trace file.
"Marcin A. Guzowski" <tu_wstaw_moje_imie@.guzowski.info> wrote in message
news:esu87d$p2a$1@.news.onet.pl...
> Hi,
>
> I'm afraid there is no way to do it. The file is encrypted as an internal
> part of DTC service.
>
> --
> Best regards,
> Marcin Guzowski
> http://guzowski.info

DTC question

Hi friends,
If I have a ms dtc log file on my hands, and it is, I believe, in some
binary format, is there any way to view it?
Thanks a lot in advanceHi,

> If I have a ms dtc log file on my hands, and it is, I believe, in some
> binary format, is there any way to view it?
I'm afraid there is no way to do it. The file is encrypted as an
internal part of DTC service.
Best regards,
Marcin Guzowski
http://guzowski.info|||It is sad.
It's actually dtc trace file.
"Marcin A. Guzowski" <tu_wstaw_moje_imie@.guzowski.info> wrote in message
news:esu87d$p2a$1@.news.onet.pl...
> Hi,
>
> I'm afraid there is no way to do it. The file is encrypted as an internal
> part of DTC service.
>
> --
> Best regards,
> Marcin Guzowski
> http://guzowski.info