Showing posts with label date. Show all posts
Showing posts with label date. 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.

Thursday, March 22, 2012

DTS Date Problem

I have a DTS package that imports from a text file into SQL 2k SP3. I am trying to insert a field (along with the imported fields) during the DTS execution that will be the current date. Does anyone know of a way to do this? I really didn't think I should have to schedule a seperate job to UPDATE each record with the current date...

Make sense?Make a datetime column in the imported table default to getdate().|||Originally posted by joejcheng
Make a datetime column in the imported table default to getdate().

hehe, thanks. That's what I was trying to do, but for some stupid reason I wasn't putting the () on the end of getdate.

Thanks

Wednesday, March 21, 2012

DTS Bulk Insert task Date problem?

Really Don't understand this and have run out of hair to pull out.

DTS package whihc has a Bulk Insert Task. The task is populated with its source filename dynamically. It has a format file which is stored locally to the box its running on.

The output file is from a unix box pipe delimited. Great dandy. All works a treat as long as I treat everything as either an INT or CHAR. But I have a couple of columns that are DATES in the format 13/02/2004.

I want these inserted into smalldatetime columns. Will settle for datetime columns though.

I get an error on every row Bulk Insert data conversion error (type mismatch) for Row X Column 11 (PostingDate) which happens to be the first date column.

Tried loading it as CHAR, SQLDATETIME and SQLDATETIM4 in the format file all to no avail. TRied it with columns in the dest table as DATETIME and SMALLDATETIME

Anyone have any ideas?What happens when you use the import wizard and make all of the column varchar and create a stage table?

Then do Audits against the data

LIKE SELECT * FROM Stage WHERE ISDATE(Col1)=0

...|||Originally posted by Brett Kaiser
What happens when you use the import wizard and make all of the column varchar and create a stage table?

Then do Audits against the data

LIKE SELECT * FROM Stage WHERE ISDATE(Col1)=0

...

Done that. All the data in the column concerned is valid. They are all dates formatted as DD/MM/YYYY.|||You sure it's considered a valid date?

DECLARE @.X varchar(10)
SELECT @.x = '23/12/2003'
SELECT ISDATE(@.x)
SELECT CONVERT(datetime,@.x,120)

Doesn't seem to be...is it a collation thing?|||Originally posted by Brett Kaiser
You sure it's considered a valid date?

DECLARE @.X varchar(10)
SELECT @.x = '23/12/2003'
SELECT ISDATE(@.x)
SELECT CONVERT(datetime,@.x,120)

Doesn't seem to be...is it a collation thing?

Don't think so. Always use US LATIN 1 General code page 437 case Sensitive for everyuthing.

Will check.

Must be something to do with the DD/MM rather than MM/DD as the column inserts fine as a CHAR.

Stupid #@.*&%$! thing|||I think (ok, well SOMETIMES...not always) that's right...it's not recognizing it as a date...

How many records are we talking about?|||Originally posted by steve@.powell.ne
Really Don't understand this and have run out of hair to pull out.

Anyone have any ideas? I resemble that hair remark!

You are using BCP's -R option, right?

-PatP|||Originally posted by Brett Kaiser
I think (ok, well SOMETIMES...not always) that's right...it's not recognizing it as a date...

How many records are we talking about?

Its booting every single one. Even when I format the data so the dates are something innofensive like 01/01/2004.

Was using the Bulk Insert task in a DTS not using the BCP command line at all.

Have abandoned Bulk Insert in favour of a scripted transform instead.

Works a treat. The files arrive daily with between 2000 and 30000 lines. So the scripted transform is fine. Even at 30,000 it's not exactly taking very long.

Ho hum.|||Did you try bcp with a fromat file?

Or how about BULK INSERT..

I rarely use DTS...|||Originally posted by Brett Kaiser
Did you try bcp with a fromat file?

Or how about BULK INSERT..

I rarely use DTS...

Didn't try the BCP or Bulk INsert route. Not much interested in command line solutions though I geuss I could chron them.

We integrate into legacy systems that spit PSV files out after each nights proocessing. We import the results each morning before we arrive to provide us with off line access to the data.

I usually use scripted routines as it lets me check for nulls and such and do some clever tricks to reduce the number of replicated columns that come out.

Just thought I'd play with something that I don't normally use.

I've got XML to bring in next.sql

Friday, March 9, 2012

DTS ActiveX BCP file manipulation

Does anyone know the best way to handle this type of situation?

A file coming into a directory based on the date filename042707
I use the fileexist stored procedure to check for the existence.
I use xp_cmdshell(sp)... stored procedure to rename the file so that
it just has filename instead of the date... I can not use
variables within the xp_cmdshell to replace the date...
everyday the filename would change to filename042807,filename042907 etc...

Basically I know how to copy the file to another directory if it exists...
then I want to strip the right 8 characters off... rename just to that
but with the rename i have to know what the file will be named for that day ...
excuse the grammar just somewhat tired...
any suggestions... please thanks time for sleep"DTS ActiveX BCP file manipulation"

what on earth are you doing with ActiveX in SQL Server?|||not sure where r u facing problem

I can not use variables within the xp_cmdshell to replace the date...

u can use variables withing xp_cmdshell like below

declare @.cmd varchar(100)
set @.cmd = 'ren d:\file042807.xls file' + replace(convert(varchar ,getdate(),1),'/','') + '.xls'
exec master..xp_cmdshell @.cmd

what on earth are you doing with ActiveX in SQL Server?

talking about ActiveX of DTS...

Sunday, February 26, 2012

Dts

Hi All,

I am trying to populate an Oracle table with the data from an Excel spreadsheet using DTS. The Excel spreadsheet has three date fields. When I run DTS one of these three fields is populated correctly and the other two just come over as blank. Any idea?

Any help is appreciated.Whenever importing data, especially from unreliable formats such as Excel, it is wise to load the records into a staging table first, and then use a stored procedure to verify, cleanse, and transfer the data to your production table.
Make the columns in your staging table NVARCHAR2, so you can see what is actually coming into them, and that will help you debug the situation.|||excel? DTS? SQL Server? oracle?

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

Tuesday, February 14, 2012

DSO on AS2005

Right now I am just working with DSO 8.5 and AS2005 in VB .NET (framework 2.0). I am trying to create an MDX statement called [Year to Date Amount] but when I do that, something puts brackets around Date to make it [Year to [Date] Amount] which will cause an MDX script error when processing it.

Someone mentioned this was a known issue and is going to be in SP2 but I was wondering if anyone knows where/if there is a hotfix for this?

Yes, I will be switching to AMO asap but I wanted to make sure what I have works with AS2005 right now (or will work with a simple patch).

Thank you.

This very much could be a known problem.

But please go ahead and file it using feedback site: http://connect.microsoft.com/SQLServer/feedback/.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.