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.

Tuesday, November 9, 2010

The entry 'XXXXX' has already been added.

Problem:



The entry 'XXXXX' has already been added.

This error has troubled me for over an hour. After deploying the libraries to test environment I have encountered this strange error.

Solution:
Went to web.config file and added


just above the

Root cause
Still havent figured it yet. But will post the solution soon as to what has happened.

Saturday, November 6, 2010

I am not sure if this holds still good. I will do some research before I publish this post. I haven't thought that I will be using SQL server again in my life but things come around in a consulting job and you will use all the databases. So hang on this post will help you to customize your sql server management studio and make your life easy.



create procedure sp_HelpTables
(
@paramTables varchar(30)
)
as
Begin
declare @strSQL varchar(500)
select @strSQL = 'select * from information_schema.Tables where table_name like ''%' + @paramTables + '%'''

Exec(@strSQL)

End
go


create procedure sp_HelpColumns
(
@paramColumn varchar(30)
)
as
Begin
declare @strSQL varchar(500)
select @strSQL = 'select * from information_schema.Columns where column_name like ''%' + @paramColumn + '%'''

Exec(@strSQL)

End
go


create procedure sp_HelpSelect
(
@paramTable varchar(50)
)
as
Begin
declare @strSQL varchar(500)
select @strSQL = 'select * from ' + @paramTable
Exec(@strSQL)
End

go

What is the fresh Windows 7 Ultimate Size after fresh install.

Well I had bought a new Solid State Drive. Kingston SSD from newegg.com.

I wanted to share with you the space it took on hard drive after every fresh install.

After the install the performance is so awesome, my 5 year old inspiron E1505 felt like the new laptop. The reason I would suggest getting a SSD is because, It takes only 20 seconds to build by solution with 50 projects in Visual studio. It is worth a try.

I have installed

  • Windows 7 ultimate.
  • Office 2010.
  • Visual Studio 2010.