Showing posts with label current. Show all posts
Showing posts with label current. Show all posts

Monday, March 26, 2012

Month-to-month function

Hi I trying to find a way to determine the number of working days per month starting from the current date to the last day of the current month.And within the same store procedure determine the number of working days as normal (each month is independent from the next). For example: The store procedure is executed

September:

@.CurrentDate = 9/10/2007

@.EndDate = last working day 9/30/2007

Total# of working days = 15

October:

@.CurrentDate = 10/1/2007

@.EndDate = last working day 10/31/2007

Total# of working days = 23

November:

@.CurrentDate = 11/1/2007

@.EndDate = last working day 11/30/2007

Total# of working days = 22

etc.

Any ideas of how i can approch this?

Thanks in advance.

If we just count out weekends, you can use this script. This will not take into account holidays.

Code Snippet

DECLARE @.startDate DATETIME,

@.dateTest DATETIME,

@.workDays INT

SET @.startDate = getDate()

SET @.dateTest = @.startDate

SET @.workDays = 0

WHILE( MONTH(@.startDate) = MONTH(@.dateTest) )

BEGIN

IF( DATENAME(dw, @.dateTest) != 'SATURDAY' AND DATENAME(dw, @.dateTest) != 'Sunday')

SET @.workDays = @.workDays + 1

SET @.dateTest = @.dateTest + 1

END

SELECT @.workDays

|||

You might try to search this forum on "Working Days". Also, give a look to this article about using a "calendar table:"

http://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using-an-auxiliary-calendar-table.html

|||

Code Snippet

create function udf_WeekdayCounter

(

@.dtFrom datetime

, @.dtThrough Datetime

)

returns smallint

as

begin

if @.dtThrough <= @.dtFrom

return 0

declare @.iCounter int

set @.iCounter = 0

/*

declare @.dtFrom datetime, @.dtThrough datetime

set @.dtFrom = '11/1/2007'

set @.dtThrough = '11/30/2007'

*/

while @.dtFrom < = @.dtThrough

begin

if datepart(weekday,@.dtFrom) not in (datepart(weekday,'December 30, 2006'), datepart(weekday,'December 31, 2006'))

set @.iCounter = @.iCounter + 1

set @.dtFrom = dateadd(d, 1, @.dtFrom)

end

return @.iCounter

end

GO

select dbo.udf_WeekdayCounter( '11/1/2007', '11/30/2007')

sql

Friday, March 23, 2012

Month data

HI,
I have a datetime column and it has 2 years of data. How
do I select the data that is only belong to the current
month (Whether it is the beginning/middle/end of the
month) '
Thanks for any help.There's a couple of different options for doing this, but this one should do
the trick:
select <insert your column list here>
from table1
where month(YourDate) = month(current_timestamp)
and year(YourDate) = year(current_timestamp)
--
--Brian
(Please reply to the newsgroups only.)
"Chris" <anonymous@.discussions.microsoft.com> wrote in message
news:5e7601c40092$e4c66910$a101280a@.phx.gbl...
> HI,
> I have a datetime column and it has 2 years of data. How
> do I select the data that is only belong to the current
> month (Whether it is the beginning/middle/end of the
> month) '
> Thanks for any help.|||Thanks.......
I found it
Select * from mytable
where column >= cast(month(getdate()) as varchar(2))
+ '/01/' + cast(year(getdate()) as varchar(4))
>--Original Message--
>There's a couple of different options for doing this, but
this one should do
>the trick:
>select <insert your column list here>
> from table1
> where month(YourDate) = month(current_timestamp)
> and year(YourDate) = year(current_timestamp)
>--
>--Brian
>(Please reply to the newsgroups only.)
>
>"Chris" <anonymous@.discussions.microsoft.com> wrote in
message
>news:5e7601c40092$e4c66910$a101280a@.phx.gbl...
>> HI,
>> I have a datetime column and it has 2 years of data. How
>> do I select the data that is only belong to the current
>> month (Whether it is the beginning/middle/end of the
>> month) '
>> Thanks for any help.
>
>.
>

Monday, March 12, 2012

Monitoring Merge Push Subscription from Subscriber

Hi all!

Is there an option to monitor current state of Merge Push Subscription from the Subscriber, without connecting to the Publisher Server? I have examined many SPs and system tables at Subscriber, but didn't find any reliable method...

What we do is record the current UTC time every time the sync job completes successfully. Then another job which sends out an alert if the last sync time is too far out of date. However another thing you can do is look at MSMerge_genhistory. There is a genstatus in there 1 or 0 for delivered or not delivered. If the last genstatus is still zero and the coldate is X number of hours out of date then you can send out some alerts.

Martin

|||

Thanks, Martin!

I also discovered, that table sysmergesubscriptions at Subscriber contains some information about when the last synchronization occured and it's message.

monitoring memory usage of particular database

We would like to individually monitor the memory usage of all the different
databases on a server. In Current Activity in Enterprise Manager I see Memor
y Usage for the databases - is there a way to log that information? I didn't
see Memory Usage as a data
column in the Trace Properties in the Profiler. Thank you.Could the Perfmon be of any help? You ahve database counters there, depends
on what information you need.
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.

monitoring memory usage of particular database

We would like to individually monitor the memory usage of all the different databases on a server. In Current Activity in Enterprise Manager I see Memory Usage for the databases - is there a way to log that information? I didn't see Memory Usage as a data
column in the Trace Properties in the Profiler. Thank you.
Could the Perfmon be of any help? You ahve database counters there, depends
on what information you need.
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.

Friday, March 9, 2012

Monitoring Changes in SP, Table and Views - Server Objects

Hello,
I would like to monitor the changes in current SQL Server Database
Objets like Tables, Stored Procedures, views and Triggers. I would like to
store the information in one table and would like to get the report.
How can i do this?Your best bet is via 3rd party tools. Take a look at the offerings of
lumigent. www.lumigent.com
HTH. Ryan
"Mehul Gurjar" <Mehul Gurjar@.discussions.microsoft.com> wrote in message
news:4C2A4D8D-BE04-4B66-9D95-6A631C11A6B9@.microsoft.com...
> Hello,
> I would like to monitor the changes in current SQL Server Database
> Objets like Tables, Stored Procedures, views and Triggers. I would like to
> store the information in one table and would like to get the report.
> How can i do this?
>|||Hello Ryan,
Thanks for the response. But can i do this using SQL server only.
The third party tool will either monitor the Changes using Processes and wil
l
be storing the Data in some database only. We have Jobs, Stored procedures
and we can run the processes from the SQL server only.
Do we have any other method except the third party tool ?
If we can do this, we can use it to all other client's environment
and can monitor the changes.
With regards,
"Ryan" wrote:

> Your best bet is via 3rd party tools. Take a look at the offerings of
> lumigent. www.lumigent.com
>
> --
> HTH. Ryan
> "Mehul Gurjar" <Mehul Gurjar@.discussions.microsoft.com> wrote in message
> news:4C2A4D8D-BE04-4B66-9D95-6A631C11A6B9@.microsoft.com...
>
>|||In SQL Server 2005 you can take a lookn at modify_date in sys.all_objects
catalog view
MS wrote that you can see the changes if you use an ALTER statement, however
modify_date will be changed if you did it direclty in the object by right
click--Modify ( I checked views) as well.
"Mehul Gurjar" <MehulGurjar@.discussions.microsoft.com> wrote in message
news:8F3AF150-AB1F-423C-B863-94D5A7010AE3@.microsoft.com...
> Hello Ryan,
> Thanks for the response. But can i do this using SQL server only.
> The third party tool will either monitor the Changes using Processes and
> will
> be storing the Data in some database only. We have Jobs, Stored procedures
> and we can run the processes from the SQL server only.
> Do we have any other method except the third party tool ?
> If we can do this, we can use it to all other client's environment
> and can monitor the changes.
> With regards,
> "Ryan" wrote:
>

Saturday, February 25, 2012

Monitor Database Mirroring

Does database mirroring have any monitoring capabilities like Log shipping
to let the DBAs know the current status of the mirrored server i.e. how far
behind the principal it is,etc. ?
See the DMV dm_db_mirroring_connections. See details from below URL:-
http://msdn2.microsoft.com/en-us/library/ms189796.aspx
Also see:-
http://msdn2.microsoft.com/en-us/library/ms365781.aspx
Thanks
Hari
"Hassan" <hassan@.hotmail.com> wrote in message
news:%23IQSavNeHHA.2332@.TK2MSFTNGP04.phx.gbl...
> Does database mirroring have any monitoring capabilities like Log shipping
> to let the DBAs know the current status of the mirrored server i.e. how
> far behind the principal it is,etc. ?
>

Monitor Database Mirroring

Does database mirroring have any monitoring capabilities like Log shipping
to let the DBAs know the current status of the mirrored server i.e. how far
behind the principal it is,etc. ?See the DMV dm_db_mirroring_connections. See details from below URL:-
http://msdn2.microsoft.com/en-us/library/ms189796.aspx
Also see:-
http://msdn2.microsoft.com/en-us/library/ms365781.aspx
Thanks
Hari
"Hassan" <hassan@.hotmail.com> wrote in message
news:%23IQSavNeHHA.2332@.TK2MSFTNGP04.phx.gbl...
> Does database mirroring have any monitoring capabilities like Log shipping
> to let the DBAs know the current status of the mirrored server i.e. how
> far behind the principal it is,etc. ?
>

Monitor Database Mirroring

Does database mirroring have any monitoring capabilities like Log shipping
to let the DBAs know the current status of the mirrored server i.e. how far
behind the principal it is,etc. ?See the DMV dm_db_mirroring_connections. See details from below URL:-
http://msdn2.microsoft.com/en-us/library/ms189796.aspx
Also see:-
http://msdn2.microsoft.com/en-us/library/ms365781.aspx
Thanks
Hari
"Hassan" <hassan@.hotmail.com> wrote in message
news:%23IQSavNeHHA.2332@.TK2MSFTNGP04.phx.gbl...
> Does database mirroring have any monitoring capabilities like Log shipping
> to let the DBAs know the current status of the mirrored server i.e. how
> far behind the principal it is,etc. ?
>

Monday, February 20, 2012

MOM Reporting Configuration Query?

My current environment is as follows:
MOM 2005 SP1 Frontend & DAS
MOM 2005 SP1 Frontend
MOM 2005 SP1 DB w/ SQL 2000 SP4
SQL Reporting Services 2000 w/ MOM 2005 SP1 Reporting Pack
Will applying SQL 2000 RS SP2 break MOM reporting?No it won't. Whilst the RTM MOM Reporting install complains if RS SP2 is
installed when you try and initially install MOM Reporting, if you apply SP2
after you have installed MOM Reporting it should be fine. I just tried this
and then added some new reports from a management pack and it worked fine.
The link below also has this quote that seems to confirm this
"With MOM 2005 Service Pack 1, you can use SQL 2000 Reporting Services SP2,
which is independent of service packs for SQL Server 2000."
http://www.microsoft.com/technet/prodtechnol/mom/mom2005/Library/1e823712-c25b-4107-941d-e078f3937f3e.mspx
--
HTH,
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
<damian.yates@.gtsi.com> wrote in message
news:1140192996.396977.158350@.g14g2000cwa.googlegroups.com...
> My current environment is as follows:
> MOM 2005 SP1 Frontend & DAS
> MOM 2005 SP1 Frontend
> MOM 2005 SP1 DB w/ SQL 2000 SP4
> SQL Reporting Services 2000 w/ MOM 2005 SP1 Reporting Pack
>
> Will applying SQL 2000 RS SP2 break MOM reporting?
>