Showing posts with label dear. Show all posts
Showing posts with label dear. Show all posts

Friday, March 23, 2012

Last working day from last year!

Dear Friends,

How can I retrieve the last working day from the currentyear-1?

Thanks

In SQL, or an expression inside SSIS?|||

Not sure what this has got to do with SSIS.

Which country are you in? Because different countries have different public holidays around the end of the year and this obviously makes a difference.

-Jamie

|||

I need to create a new column with the last working day for each row in the datasource... as for example inside a derived column...

How can I do it?

And I have the problem about holidays... but could be resolved if I have a table wich indicate the holidays for this case in my country Portugal... or have to apply for all the cases using a key to each country...

could help me?

Thanks!!

|||How can I get the last working day for the last year for each row in data source.. how can I include it inside a transform like derivaded column?
Help me!!|||

PedroCGD wrote:

How can I get the last working day for the last year for each row in data source.. how can I include it inside a transform like derivaded column?
Help me!!

What is considered the last working day of the year? The last Friday?|||YES|||

This is usually a table-driven information item such as a time dimension table. The DIMTIME records would be flagged for weekdays.

As Jamie mentioned, holidays are a regional thing so you would join entries in a DIMTIME table against a local holiday table to derive a list of working days. Then you could query the join to find the last working day of a given year.

This is not a SSIS issue, but a TSQL or engine question.

|||

No Benda, forget the holidays....

I need to transform each row, to add a new column that for each date I need to get the Reference Rate that is the last day of the last year for the each row of the data source....

thanks

|||This assumes you have a VARIABLE containing the year. If you don't have that, and need to dynamically read the year, replace the variable here with DATEPART("yyyy",[your_date_field])

So you'd replace "(DT_WSTR,4)@.[User::Year]" with "DATEPART("yyyy",[your_date_field])" if that's the case.

DATEPART("dw",(DT_DBDATE)("12/31/" + (DT_WSTR,4)@.[User::Year])) < 6 ? DATEADD("d",-1 * (DATEPART("dw",(DT_DBDATE)("12/31/" + (DT_WSTR,4)@.[User::Year])) + 1),(DT_DBDATE)("12/31/" + (DT_WSTR,4)@.[User::Year])) : DATEPART("dw",(DT_DBDATE)("12/31/" + (DT_WSTR,4)@.[User::Year])) > 6 ? DATEADD("d",-1,(DT_DBDATE)("12/31/" + (DT_WSTR,4)@.[User::Year])) : (DT_DBDATE)("12/31/" + (DT_WSTR,4)@.[User::Year])|||

Phil,

i was cheking the dates, and your code is not returning the last working day of the year, in spite is returning the saturday...

My last working day of a week is friday not saturday! :-)

Where you define it in your code?

Thanks!

|||

PedroCGD wrote:

Phil,

i was cheking the dates, and your code is not returning the last working day of the year, in spite is returning the saturday...

My last working day of a week is friday not saturday! :-)

Where you define it in your code?

Thanks!

That's a locale issue then... DATEPART("dw",[datefield]) == 6 for Fridays here in the US.

Never the less, you should be able to adjust the logic by playing around with it a bit. Try to read the expression I've built for you and work on it your own. It's pretty simple logic, really, despite the fact the expression looks complicated.|||your code in US give you the friday?|||

PedroCGD wrote:

your code in US give you the friday?

Yes, absolutely. I tested it for several years. 2006 = 12/29/2006 = Friday|||

your code for me gives me 2006 = 12/30/2006 = Saturday!

:-(

bbrrr.... :-(

Monday, March 19, 2012

Last Modified Date of the Database Object ?

Dear All,
In order to get a version control.
I would like to get the last modified date of the Store Procedure, Table De
finition
I find the the [sysobjects] Table ONLY contains a Create Date.
How can i find it.
Do SQL Server remember the [ALTER] and [RECOMPILE] time of these objects
Thank you very much
EricLunCurrent versions of SQL Server do not track modifications to objects, only
creation. You will have to track these yourself, or use a third party
product to do so. Your version control strategy, by the way, should not
rely on a feature of the product. In other words, if you were using version
control tools, you should have alter scripts stored in your source control
tool, without having to look at the database (other than to verify that what
is deployed exists in source control, or vice versa).
http://www.aspfaq.com/2495
Yukon will offer DDL triggers, but that's several months away, at least.
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"EricLun >" <eric_klyuen@.yahoo.com.hk <no spam pls> wrote in message
news:DCE9AA09-6AF7-4BFD-A576-6D730BD4D79B@.microsoft.com...
quote:

> Dear All,
> In order to get a version control.
> I would like to get the last modified date of the Store Procedure, Table

Definition
quote:

> I find the the [sysobjects] Table ONLY contains a Create Date.
> How can i find it.
> Do SQL Server remember the [ALTER] and [RECOMPILE] time of these objects
> Thank you very much
> EricLun
|||Thank you very much form your help.

Last Modified Date of the Database Object ?

Dear All,
In order to get a version control.
I would like to get the last modified date of the Store Procedure, Table Definition
I find the the [sysobjects] Table ONLY contains a Create Date.
How can i find it.
Do SQL Server remember the [ALTER] and [RECOMPILE] time of these objects
Thank you very much
EricLunCurrent versions of SQL Server do not track modifications to objects, only
creation. You will have to track these yourself, or use a third party
product to do so. Your version control strategy, by the way, should not
rely on a feature of the product. In other words, if you were using version
control tools, you should have alter scripts stored in your source control
tool, without having to look at the database (other than to verify that what
is deployed exists in source control, or vice versa).
http://www.aspfaq.com/2495
Yukon will offer DDL triggers, but that's several months away, at least.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"EricLun >" <eric_klyuen@.yahoo.com.hk <no spam pls> wrote in message
news:DCE9AA09-6AF7-4BFD-A576-6D730BD4D79B@.microsoft.com...
> Dear All,
> In order to get a version control.
> I would like to get the last modified date of the Store Procedure, Table
Definition
> I find the the [sysobjects] Table ONLY contains a Create Date.
> How can i find it.
> Do SQL Server remember the [ALTER] and [RECOMPILE] time of these objects
> Thank you very much
> EricLun|||Thank you very much form your help.

Monday, February 20, 2012

large inserts

Dear Experts,

What is the best way to do a large insert WITHOUT having direct access
to the machine SQL Server is running on? For example, imagine I want
to insert something like 20,000 records. If I were to have access to
the server, I could BULK INSERT into a temp table and then insert into
the destination table. But if I can't create a file on the server to
use for BULK INSERT, what is the next best alternative to doing lots
of 1 record insert statements?

Thanks,
-EminOn Thu, 05 Jul 2007 17:34:42 -0000, Emin <emin.shopper@.gmail.com>
wrote:

Quote:

Originally Posted by

>Dear Experts,
>
>What is the best way to do a large insert WITHOUT having direct access
>to the machine SQL Server is running on? For example, imagine I want
>to insert something like 20,000 records. If I were to have access to
>the server, I could BULK INSERT into a temp table and then insert into
>the destination table. But if I can't create a file on the server to
>use for BULK INSERT, what is the next best alternative to doing lots
>of 1 record insert statements?
>
>Thanks,
>-Emin


The Bulk Copy command line utility BCP.EXE is one alternative, as are
DTS (SQL Server 2000) and SSIS (2005) executing locally.

Roy Harvey
Beacon Falls, CT|||Doesn't the client need something like SQL Management studio installed
to use DTS or SSIS? Ideally, I'd like something where the client can
just connect to the database using odbc or ado and do the insert as
opposed to requiring the client to have special software installed.

Thanks,
-Emin

On Jul 5, 5:28 pm, Roy Harvey <roy_har...@.snet.netwrote:

Quote:

Originally Posted by

>
The Bulk Copy command line utility BCP.EXE is one alternative, as are
DTS (SQL Server 2000) and SSIS (2005) executing locally.
>
Roy Harvey
Beacon Falls, CT

|||On Jul 5, 12:34 pm, Emin <emin.shop...@.gmail.comwrote:

Quote:

Originally Posted by

Dear Experts,
>
What is the best way to do a large insert WITHOUT having direct access
to the machine SQL Server is running on? For example, imagine I want
to insert something like 20,000 records. If I were to have access to
the server, I could BULK INSERT into a temp table and then insert into
the destination table. But if I can't create a file on the server to
use for BULK INSERT, what is the next best alternative to doing lots
of 1 record insert statements?
>
Thanks,
-Emin


You can put your file in a shared folder - BULK INSERT can read it if
it is accessible by the account SQL Server runs under.

Alex Kuznetsov, SQL Server MVP
http://sqlserver-tips.blogspot.com/|||You don't need the full set of client tools to run DTS packages, just
the dtsrun.exe utility. And for SSIS packages there is the dtexec
command line utility, though I have not used it. And as Erland said,
for BCP you need bcp.exe.

Roy Harvey
Beacon Falls, CT

On Thu, 05 Jul 2007 21:55:53 -0000, Emin <emin.shopper@.gmail.com>
wrote:

Quote:

Originally Posted by

>Doesn't the client need something like SQL Management studio installed
>to use DTS or SSIS? Ideally, I'd like something where the client can
>just connect to the database using odbc or ado and do the insert as
>opposed to requiring the client to have special software installed.
>
>Thanks,
>-Emin
>
>On Jul 5, 5:28 pm, Roy Harvey <roy_har...@.snet.netwrote:

Quote:

Originally Posted by

>>
>The Bulk Copy command line utility BCP.EXE is one alternative, as are
>DTS (SQL Server 2000) and SSIS (2005) executing locally.
>>
>Roy Harvey
>Beacon Falls, CT


>