GET ROWCOUNTS FOR ALL TABLES
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.rows)
FROM        sysobjects so,
sysindexes si
WHERE so.xtype = 'U'
AND si.id = OBJECT_ID(so.name)
GROUP BY so.name
ORDER BY 2 DESC 

GET REFERENCES OF DATABASE OBJECTS
SELECT  OBJECT_NAME (referencing_id) AS referencing_object, referenced_database_name,
     referenced_schema_name, referenced_entity_name
FROM sys.sql_expression_dependencies
WHERE referenced_database_name IS NOT NULL
      AND is_ambiguous = 0
  ORDER BY referenced_entity_name desc


SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%TableName%'

DETERMINE WHEN A STORED PROCEDURE WAS CREATED AND LAST ALTERED
select
SPECIFIC_NAME AS procedureName,
SPECIFIC_CATALOG AS databaseName,
CREATED AS createDate,
LAST_ALTERED as lastAlteredDate
from
information_schema.routines
where routine_name = '<Procedure Name Here>'

FIND COLUMN IN ALL TABLES
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%ColumnName%'
ORDER BY schema_name, table_name


UDPATE WITH JOIN
UPDATE
    tbl_User
SET
    sShortUserID = sui.sShortUserID
FROM
    tbl_User u
    JOIN
    tbl_ShortUserIDs sui ON u.uSystemUserID=sui.uSystemUserID

select u.uSystemUserID,u.sShortUserID,sui.uSystemUserID,sui.sShortUserID FROM
    tbl_User u
    JOIN
    tbl_ShortUserIDs sui ON u.uSystemUserID=sui.uSystemUserID


REPLACE IN A ROW

UPDATE dbo.tbl_UserLiveStreamPlayback
SET sPlaybackURL = REPLACE(sPlaybackURL,'SourceText','ReplaceByText')


SELECT SP CONTAINING SPECIFIC TEXT
SELECT OBJECT_NAME(id)
    FROM syscomments
    WHERE [text] LIKE '%TextToSearch%'
    AND OBJECTPROPERTY(id, 'IsProcedure') = 1
    GROUP BY OBJECT_NAME(id)


TO COUNT NUMBER OF TABLES IN A DB
  SELECT [TABLECOUNT] = COUNT(OBJ.ID) FROM SYSOBJECTS OBJ WHERE XTYPE='U'

TO COUNT NUMBER OF STORED PROCEDURES IN A DB
  SELECT [SPCOUNT] = COUNT(OBJ.ID) FROM SYSOBJECTS OBJ WHERE XTYPE='P'


GET LIST OF TABLES NAMES AND THEIR ROW COUNTS
  SELECT [TABLENAME] = OBJ.NAME, [ROWCOUNT] = MAX(SI.ROWS) FROM SYSOBJECTS OBJ,
  SYSINDEXES SI WHERE OBJ.XTYPE = 'U' AND SI.ID = OBJECT_ID(OBJ.NAME)
  GROUP BY OBJ.NAME ORDER BY [ROWCOUNT] DESC


GET COLUMNS NAMES, DATA TYPES, IS NULLABLE OF A PARTICULAR TABLE
  SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE + CASE ISNULL(CHARACTER_MAXIMUM_LENGTH,'')
  WHEN '' THEN '' ELSE ' (' + CAST (CHARACTER_MAXIMUM_LENGTH AS VARCHAR(6)) + ')'
  END AS [DATA TYPE], CASE IS_NULLABLE WHEN 'YES' THEN 'NULL' ELSE 'NOT NULL'
  END AS [NULL OR NOT] FROM INFORMATION_SCHEMA.COLUMNS WHERE
  TABLE_NAME = 'L_SAMPLE' ORDER BY TABLE_NAME, COLUMN_NAME


TO SEE THE DEFINITION OF A SP 
  EXEC SP_HELPTEXT GET_USER_DATA


GET TABLES CREATION AND MODIFIED DATES
  SELECT [TABLENAME] = NAME, CREATE_DATE, MODIFY_DATE FROM SYS.OBJECTS
  WHERE TYPE = 'U' --AND NAME LIKE '%L_%' 
  ORDER BY MODIFY_DATE DESC


GET STORED PROCEDURES CREATION AND MODIFIED DATES
  SELECT [SPNAME] = NAME, CREATE_DATE, MODIFY_DATE FROM SYS.OBJECTS
  WHERE TYPE = 'P' --AND NAME LIKE '%GET%' 
  ORDER BY MODIFY_DATE DESC

GET TABLES THAT ARE NOT USED
select t.name, sys.objects.name foundin, sys.objects.type_desc
from sys.objects t
left outer join
    sys.sql_modules
    inner join sys.objects on sys.objects.object_id = sys.sql_modules.object_id
on sys.sql_modules.definition like '%' + t.name + '%'
where t.type = 'U'
and sys.objects.name is null
order by t.name, type_desc, foundin

FIND MOST EXPENSIVE STORED PROCEDURE
SELECT DB_NAME(SQTX.DBID) AS [DBNAME]
,OBJECT_SCHEMA_NAME(SQTX.OBJECTID, DBID) AS [SCHEMA]
,OBJECT_NAME(SQTX.OBJECTID, DBID) AS [STORED PROC]
,MAX(CPLAN.USECOUNTS) [EXEC COUNT]
FROM SYS.DM_EXEC_CACHED_PLANS CPLAN
CROSS APPLY SYS.DM_EXEC_SQL_TEXT(CPLAN.PLAN_HANDLE) SQTX
WHERE DB_NAME(SQTX.DBID) IS NOT NULL
AND CPLAN.OBJTYPE = 'PROC'
GROUP BY CPLAN.PLAN_HANDLE
,DB_NAME(SQTX.DBID)
,OBJECT_SCHEMA_NAME(OBJECTID, SQTX.DBID)
,OBJECT_NAME(OBJECTID, SQTX.DBID)
ORDER BY MAX(CPLAN.USECOUNTS) DESC


Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530
Hello all,

Here i come with the best way to send the push notifications to iOS devices using Amazon Simple Notification Services in C# .Net

So here is the snippet that can push the notification very easily..

string[] strTokens = txtTokens.Text.Split(','); // Get all tokens to send the code
Parallel.ForEach(strTokens , sToken =>
                {
                    HttpContext ctx = HttpContext.Current;
                    new System.Threading.Thread(() =>
                    {
                        HttpContext.Current = ctx;
                        SendNotificationAsync(sToken , "Your Notification Message" , 0 , "default");
                    }).Start();
                });


 public void SendNotificationAsync(string sToken , string sMessage , int iBadge , string sSound)
        {
            try
            {
                string Platform = ConfigurationManager.AppSettings["Platform"];// Application Platform
                string ApplicationName = ConfigurationManager.AppSettings["ApplicationName"];//Application Name configured on SNS
                string PlatformApplicationArn = ConfigurationManager.AppSettings["PlatformApplicationArn"];

                AmazonSimpleNotificationServiceClient objsnsClient = new AmazonSimpleNotificationServiceClient("AWSAccessKey" , "AWSSecretKey" , "Region");
                var objResponse = objsnsClient.CreatePlatformEndpointExtended(new CreatePlatformEndpointRequest
                {
                    Token = sToken ,
                    PlatformApplicationArn =
                    PlatformApplicationArn
                });


                Dictionary<string , string> CustomParams = new Dictionary<string , string>();
                CustomParams.Add("default" , sMessage);
                CustomParams.Add("" + Platform + "" , "{\"aps\":{\"alert\": \"" + sMessage + "\",\"sound\" :\"" + sSound + "\"},\"ShortUserID\":\"123456\",\"NotificationType\":\"10\"}");
                objsnsClient.Publish(new PublishRequest
                {
                    Message = JsonConvert.SerializeObject(CustomParams) ,
                    MessageStructure = "json" ,
                    TargetArn = objResponse.EndpointArn
                });
            }
            catch (Exception ex)
            {
            }
        }

Ravi Tuvar – IntelliMedia Networks
Technical Manager
Cell: (+91) 73837-94530

Hey friends,

Here i am sharing a cool stuff for SQL Developers
 
Please use the following query when concatenate multiple rows with a single  comma separated string(row)
 DECLARE @iXml xml;
 
    SELECT @iXml = (
      SELECT ProductName + ','
      FROM Northwind.dbo.Products
      FOR XML PATH);
 
    SELECT @iXml.value('.','nvarchar(max)');  

or the other way is


 SELECT STUFF((SELECT ',' + RTRIM(ProductName ) FROM Products FOR XML PATH('')),1,1,'') AS 'Products'

Now this block will return a string with comma separated rows..

If you want to get the distinct values with comma separated row..

Then do this  

 DECLARE @iXml xml;
 
    SELECT @iXml = (
      SELECT distinct ProductName + ','
      FROM Northwind.dbo.Products
      FOR XML PATH);
 
    SELECT @iXml.value('.','nvarchar(max)');  
OR:
 SELECT STUFF((SELECT Distinct ',' + RTRIM(ProductName ) FROM Products FOR XML PATH('')),1,1,'') AS 'Products'

Thanks  


Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530
Still India is a 3rd World Country, Why?


Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530
It's never too late to discover that those boring, all-white headphones Apple threw in with your iPhone can do a lot more than adjust the volume.

In fact, any headphones that include a remote (or have a remote adapter attached) can be used to control your iPhone, iPad, or iPod Touch in up to 10 ways.

Thanks to this post by Business Insider, here are all the ways you can use your headphones as a remote controller, allowing you to perform useful functions without taking your iDevice out of your pocket.


  1.     If you're listening to music, toggle pause or play by tapping the center button once.
  2.     To fast-forward a song, tap the center button twice and long-press on the second tap.
  3.     To rewind a song, tap three times and long-press on the third tap.
  4.     To skip a song, double tap.
  5.     To go to the previous song, triple tap.
  6.     If you have an incoming call, tap the center button once to answer. Tap again to hang up.
  7.     To ignore an incoming call, long-press the center button. You'll hear two beeps to confirm that     the caller was sent to voice mail.
  8.     If you're on the phone and you get a new call, tap the center button once to switch calls. To end that new call, hold the center button down for 2 seconds.
  9.     You can achieve supersteady shots by using your headphones as a shutter release. Tap the volume-up button to capture a photo.
  10.     For iPhone 4S owners: prompt Siri by long-pressing the center button.



Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530

function naturalSort(a, b) {
   a = a.path.toLowerCase();
   b = b.path.toLowerCase();
   var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
  sre = /(^[ ]*|[ ]*|[_]*$)/g,
  dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
  hre = /^0x[0-9a-f]+$/i,
  ore = /^0/,
   // convert all to strings and trim()
  x = a.toString().replace(sre, '') || '',
  y = b.toString().replace(sre, '') || '',
   // chunk/tokenize
  xN = x.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0'),
  yN = y.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0'),
   // numeric, hex or date detection
  xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
  yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null;
   // first try and sort Hex codes or Dates
   if (yD)
    if (xD < yD) return -1;
    else if (xD > yD) return 1;
   // natural sorting through split numeric strings and default strings
   for (var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
    // find floats not starting with '0', string or 0 if not defined (Clint Priest)
    oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
    oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
    // handle numeric vs string comparison - number < string - (Kyle Adams)
    if (isNaN(oFxNcL) !== isNaN(oFyNcL)) return (isNaN(oFxNcL)) ? -1 : 1;
    // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
    else if (typeof oFxNcL !== typeof oFyNcL) {
     oFxNcL += '';
     oFyNcL += '';
    }
    if (oFxNcL <= oFyNcL) return -1;
    if (oFxNcL >= oFyNcL) return 1;
   }
   return 0;
  }



Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530



Hey friends so many times we need to clear the data in a dropdown list or list box...

So here is the way to remove all data frop dropdown list..!

$('#selectlist option').each(function(i, option){ $(option).remove(); });

Hope you enjoyed...



" There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies. "


Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530



Following is a letter to his son from a renowned Hong Kong TV broadcaster cum Child Psychologist.


The words are actually applicable to all of us, young or old, children or
parents.!

I am writing this to you because of 3 reasons

1. Life, fortune and mishaps are unpredictable, nobody knows how long he
lives. Some words are better said early.

2. I am your father, and if I don't tell you these, no one else will.

3. What is written is my own personal bitter experiences that perhaps
could save you a lot of unnecessary heartaches.


Remember the following as you go through life

1. Do not bear grudge towards those who are not good to you. No one has
the responsibility of treating you well, except your mother and I.

To those who are good to you, you have to treasure it and be thankful, and
ALSO you have to be cautious, because, everyone has a motive for every
move.

When a person is good to you, it does not mean he really likes you. You
have to be careful, don't hastily regard him as a real friend.

2. No one is indispensable, nothing in the world that you must possess.
Once you understand this idea, it would be easier for you to go through
life when people around you don't want you anymore, or when you lose
what/who you love most.

3. Life is short. When you waste your life today, tomorrow you would find
that life is leaving you. The earlier you treasure your life, the better
you enjoy life.

4. Love is but a transient feeling, and this feeling would fade with time
and with one's mood.

If your so called loved one leaves you, be patient, time will wash away
your aches and sadness. Don't over exaggerate the beauty and sweetness of
love, and don't over exaggerate the sadness of falling out of love.

5. A lot of successful people did not receive a good education, that does
not mean that you can be successful by not studying hard!

Whatever knowledge you gain is your weapon in life. One can go from rags
to riches, but one has to start from some rags!

6. I do not expect you to financially support me when I am old, neither
would I financially support your whole life.

My responsibility as a supporter ends when you are grown up.

After that, you decide whether you want to travel in a public transport or
in your limousine, whether rich or poor.

7. You honour your words, but don't expect others to be so.

You can be good to people, but don't expect people to be good to you. If
you don't understand this, you would end up with unnecessary troubles.

8. I have bought lotteries for umpteen years, but I never strike any
prize.

That shows if you want to be rich, you have to work hard!

There is no free lunch!

9. No matter how much time I have with you, let's treasure the time we
have together. We do not know if we would meet again in our next life .

Your Ever loving Dad.




Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530
Dear friends,

Here is the worldwide audience statistics for CodeAssistant



Thanks all for your best response...!
It inspire me to go ahead with the best posts ever..!

Thank you,


Ravi Tuvar – IntelliMedia Networks
Software Developer
Cell: (+91) 73837-94530