Tuesday, May 23, 2017

Tuesday, May 9, 2017

Rebinding events of jQuery in ASP.net

if you are facing an issue of controls rebinding events of jQuery in ASP.net

<script>
function pageLoad(sender, args)
{
   if (args.get_isPartialLoad())
   {
       //Specific code for partial postbacks can go in here.
   }
}
</script>

Reference :
http://stackoverflow.com/questions/301473/rebinding-events-in-jquery-after-ajax-update-updatepanel

Thursday, May 4, 2017

SQL Hacks

These are some script hacks that can help you.


This is the script when you need to checkout that how many store procedure use this table.


SELECT distinct t.TABLE_NAME, s.ROUTINE_NAME,s.SPECIFIC_SCHEMA
FROM INFORMATION_SCHEMA.TABLES t
INNER JOIN INFORMATION_SCHEMA.ROUTINES s
ON s.ROUTINE_NAME IN
(
        SELECT referencing_entity_name
        FROM sys.dm_sql_referencing_entities('dbo.abc_tablename', 'OBJECT')
)
AND s.ROUTINE_TYPE = 'PROCEDURE'
WHERE t.TABLE_TYPE = 'BASE TABLE'
and table_name='abc_tablename'


-- this query duplicate the item for example if  the same Store procedure use this table 2 time it will show same Store procedure name 2 times

SELECT OBJECT_NAME(id) ObjectName , [Text]
FROM syscomments
WHERE TEXT LIKE '%abc_tablename%'




This is the script when you do not know exactly the table name and some body tell you go to this table that some name like this .. So this query will help you out

SELECT *
FROM sysobjects
WHERE name LIKE '%abc_tablename%' and xtype='U'



This is the script when you need to checkout that how many table use this column name

select * from INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME like '%user%'
order by TABLE_NAME



This script give the all columns name for that table.There is also short-cut select table name and hit alt+f1
select *
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME='abc_tablename'

Tuesday, May 2, 2017

Dealing NULL and Empty value in SQL

Dealing with null data become hectic.I need to put '-' when the column is NULL  but when I am digging in to data I found there are empty data as well
so if you put IS NULL check it will not work so there is a hack

 ISNULL((CASE WHEN  datalength(COLUMN_NAME)=0 THEN (NULL) ELSE COLUMN_NAME  END), '-')