Tuesday, December 28, 2010

How to find the recently modified stored procedures.

Working with offshore resources can be a daunting task at times. We need to take care of what has been modified and move it across environments. This neat script will do the trick for ya.

SELECT name as 'Name' ,create_date as 'Date Created',modify_date as 'Date Modified',
Case DATEDIFF(dd,modify_date,GETDATE()) when '0' Then 'Today'
when '1' Then 'Yesterday'
when '2' Then 'Day before Yesterday'
else 'Few days back'
End AS 'When modified',
DATEDIFF(dd,modify_date,GETDATE()) as 'How days days back'

FROM sys.procedures
WHERE DATEDIFF(dd,modify_date,GETDATE()) < 15
order by modify_date desc

How to inform the user that the session is going to end in next few minutes due to inactivity.

Write code in masterpage.
protected override void OnInit(EventArgs e)
{
if (!(Request.Url.ToString().IndexOf("Login.aspx") > 0) && InternalSession.InternalUserInformation!=null)
{
base.OnInit(e);
string script = "window.setTimeout(\"SessionEnd('" + ResolveClientUrl("~/Logout.aspx") + "');\"," + (Session.Timeout - 1) * 60000 + ");";
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "SessionTimeout", script, true);
}
}


Js file.
In the Javascript file put the below code.
function SessionEnd(url) {
alert('**ATTENTION** There has been no activity for the last 15 minutes Your session will expire in 5 minutes. If you perform no action before it expires, you will be required to log in again');
}

Wednesday, December 22, 2010

How to reseed a table is SQL server

Today, I was asked to reseed a table. I went to object explorer and tried to changed the seed to 50000. It didn't allow me to make the changes. The message that I got back was to drop and recreate the table. After some research I found an easier way to do it.

DBCC CHECKIDENT (MedicalSchoolApplicant, reseed, 49999).

Thank you, Pinal Dave for your suggestion.