Friday, September 28, 2007

JavaScript@ Validation Functions

1- Empty Field Validation:- (To check whether a text field is empty or not)

function IsEmpty(aTextField) {
if ((aTextField.value.length==0)
(aTextField.value==null)) {
return true;
}
else { return false; }
}
////////////////////////////////////////////////

2- Numeric Validation:- (To check whether a text field contains Numeric Values)

function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;


for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;

}
////////////////////////////////////////////////

3- Aplphabet Validation:- (To check whether a text field contains Alphabetic Values)


function IsAlphabet(sText)
{
var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var IsAlpha=true;
var Char;


for (i = 0; i < sText.length && IsAlpha == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsAlpha= false;
}
}
return IsAlpha;

}
/////////////////////////////////////////////////////////////////////////

3- Email Address Validation:- (To check whether a text field contains valid email value)


function isValidEmail(str) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}

Monday, September 24, 2007

SQL Server @ To List The Database Names along with their Size

The following system stored procedure is helpful to list the all database names along with their size in KiloBytes:

EXEC sp_databases

Results:
--------------------------------
DataBase_Name DataBase_Size REMARKS
HighFall_Rockin 3712 NULL
master 4608 NULL
model 1728 NULL
msdb 7360 NULL
tempdb 19456 NULL
TLSPFX 4689152 NULL
TLSPFX_BK 987008 NULL

SQL Server @ Query To List Available Triggers On a DataBase

The following query is helpful to enlist all the available triggers on a specific database. sys.triggers is a view that contains a row for each object that is a trigger.

Here is the query:

USE MSDB -- Database Name Here
SELECT name,type,type_desc,create_date,modify_date
FROM sys.triggers


Results:
---------------------------------------------------------
name type type_desc create_date modify_date

trig_sysmail_profile_delete TR SQL_TRIGGER 2005-10-14 01:55:32.520 2005-10-14 02:02:31.787
trig_sysmail_servertype TR SQL_TRIGGER 2005-10-14 01:55:32.740 2005-10-14 02:02:31.850
trig_sysmail_server TR SQL_TRIGGER 2005-10-14 01:55:33.067 2005-10-14 02:02:31.910
trig_sysmail_configuration TR SQL_TRIGGER 2005-10-14 01:55:33.287 2005-10-14 02:02:31.943
trig_sysmail_mailitems TR SQL_TRIGGER 2005-10-14 01:55:33.507 2005-10-14 02:02:31.990
trig_backupset_delete TR SQL_TRIGGER 2005-10-14 01:55:16.113 2005-10-14 02:02:32.007
trig_sysmail_attachments TR SQL_TRIGGER 2005-10-14 01:55:33.723 2005-10-14 02:02:32.050
trig_sysmail_log TR SQL_TRIGGER 2005-10-14 01:55:33.943 2005-10-14 02:02:32.100
trig_sysoriginatingservers_delete TR SQL_TRIGGER 2005-10-14 01:54:09.833 2005-10-14 02:02:32.397
trig_sysjobs_insert_update TR SQL_TRIGGER 2005-10-14 01:54:10.490 2005-10-14 02:02:32.520
trig_sysschedules_insert_update TR SQL_TRIGGER 2005-10-14 01:54:12.677 2005-10-14 02:02:33.210
trig_targetserver_insert TR SQL_TRIGGER 2005-10-14 01:55:08.570 2005-10-14 02:02:34.740
trig_notification_ins_or_upd TR SQL_TRIGGER 2005-10-14 01:55:14.583 2005-10-14 02:02:35.333
trig_notification_delete TR SQL_TRIGGER 2005-10-14 01:55:14.910 2005-10-14 02:02:35.363
trig_sysmail_profile TR SQL_TRIGGER 2005-10-14 01:55:31.647 2005-10-14 02:02:35.787
trig_principalprofile TR SQL_TRIGGER 2005-10-14 01:55:31.867 2005-10-14 02:02:35.833
trig_sysmail_account TR SQL_TRIGGER 2005-10-14 01:55:32.083 2005-10-14 02:02:35.863
trig_sysmail_profileaccount TR SQL_TRIGGER 2005-10-14 01:55:32.303 2005-10-14 02:02:35.910

SQL Server @ Query To List The available SQL JOBS

The following query is helpful to enlist the name, created date, modified date and description of the Sql Jobs available. You can add the mre column in the result set if needed.

USE MSDB

SELECT name,enabled,date_created,date_modified,description
FROM sysjobs

Results:
-------------------------------------------------------------
Name Enabled Date Created Date Modified
GEServiceEntries 1 2007-04-11 11:25:49.897 2007-04-11 11:54:05.503
CDW_CORFXSQL01_CORFXSQL01_0 1 2006-02-28 19:51:08.967 2006-02-28 19:51:09.217
DataEntryHHReports 1 2006-11-03 13:25:36.230 2007-09-20 11:43:29.297

SQL Server@ Query To See the Execution History of SQL JOBS

I have made a couple of SQL jobs that are scheduled accordingly to perform some specific tasks. I wanted to know whether the jobs are executed accordingly or not? And what are the results of the execution? Means success or failure. And finally, I created a query for this purpose after looking into the MSDB. Here is it:

USE MSDB

SELECT j.name,h.run_status,h.run_date,h.run_time, h.run_duration,h.server, h.message
FROM sysjobhistory h,sysjobs j
WHERE h.job_id=j.job_id
ORDER BY run_date desc ,run_time desc

Here are the results: (NOTE: I have omitted the Message column here)
-----------------------------------------------------------------------------
DataEntryHHReports 1 20070921 121000 0 CORFXSQL01
DataEntryHHReports 1 20070921 121000 1 CORFXSQL01
DataEntryHHReports 0 20070914 121301 0 CORFXSQL01
DataEntryHHReports 2 20070914 121001 0 CORFXSQL01
DataEntryHHReports 0 20070914 121000 301 CORFXSQL01
GEServiceEntries 1 20070911 0 0 CORFXSQL01
GEServiceEntries 1 20070911 0 1 CORFXSQL01
DataEntryHHReports 1 20070907 121000 1 CORFXSQL01
DataEntryHHReports 1 20070907 121000 1 CORFXSQL01
DataEntryHHReports 1 20070831 121001 0 CORFXSQL01
DataEntryHHReports 1 20070831 121000 1 CORFXSQL01
DataEntryHHReports 1 20070824 121001 0 CORFXSQL01
DataEntryHHReports 1 20070824 121000 1 CORFXSQL01
DataEntryHHReports 1 20070817 121000 0 CORFXSQL01
DataEntryHHReports 1 20070817 121000 0 CORFXSQL01
GEServiceEntries 1 20070811 0 0 CORFXSQL01
GEServiceEntries 1 20070811 0 0 CORFXSQL01


Monday, September 3, 2007

SQL Server@ List Stored Procedure Names using specific table

Sometimes you need to drop some table or needs to modify the name of the table, and before doing that you want to make sure which are the stored procedures that are using this table?

Secondly, you just want to update the table by deleting it's some column, and you want to make sure which are the stored procedures that are using this column?

The following query gives you the list of Stored procedures that are using some specific table name "CDRMaster".

SELECT Name, create_date,modify_date
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%CDRMaster%'

The following query will give you the list of the stored procedures using some specific column name(CDRID in this case)of the table CDRMaster:

SELECT Name, create_date,modify_date
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%CDRMaster%'
AND OBJECT_DEFINITION(object_id) LIKE '%CDRID%'


SQL Server@ List Stored Procedure Names Created in Specific Date Range

This simple query returns the list of stored procedure names that are created with in the specific data range given in where clause.

SELECT Name,create_date,modify_date
FROM sys.procedures

WHERE create_date between '07/14/2007' and '08/20/2007'