Sunday, September 21, 2014

How To Encrypt Stored Procedure In SQL Server

There are some situations where business logics wants to hide the logic implementation, in those scenarios schema of the stored procedure can be encrypted.

Use AdventureWorks2008
go

CREATE PROCEDURE uspEncryptedPersonAddress
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT ON
SELECT * FROM Person.Address
END


If some one try to view using sp_helptext this is what they see


The text for object 'uspEncryptedPersonAddress' is encrypted.

Thursday, September 11, 2014

How To Display Current Time on Page using Javascript

Here is the JavaScript function which will get current time in Military format.

<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('Showtime').innerHTML=h+":"+m+":"+s;
t=setTimeout(function(){startTime()},500);
}

function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>