Tags » SQL Query

To get a report of all printers connected to a computer using SCCM reports

I had to find a way to get all the printers attached to a particular host computer by using SQL reporting services.

Prerequisite – Please make sure that “Printer Device” and “Printer Share” classes has been enabled in hardware inventory. 108 more words


Create SQL Script to restore Transaction logs

I was part of a Major incident this week and we had to restore days worth of transaction logs on multiple databases.

Created SQL Query which generates the restore script… 111 more words


SQL Query: Find all indexes, fragmention, and rebuild in the Database

–Find all the indexes in the database, find the index fragmention size in percentage, reorganize or rebuild indexes

— Find the average fragmentation percentage of all indexes… 1,813 more words

SQL Query

Get table or view name by search column name keyword

Here is the script:

SELECT c.object_id,
     WHEN OBJECTPROPERTY(c.object_id, 'isTable') = 1
     THEN 'Yes' ELSE 'No' END AS IsTable,
     WHEN OBJECTPROPERTY(c.object_id, 'isView')  = 1
     THEN 'Yes' ELSE 'No' END AS IsView,
 OBJECT_SCHEMA_NAME(c.object_id) AS SchemaName,
 OBJECT_NAME(c.object_id) AS TableName,
 c.name AS ColumnName
 FROM sys.columns c
 WHERE c.name LIKE '%MyColumnName%'

Find Drive size and free space using TSQL

  vs.volume_mount_point AS ,
  vs.logical_volume_name AS ,
  vs.total_bytes/1024/1024 AS ,
  vs.available_bytes/1024/1024 AS 
FROM sys.master_files AS mf
CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.file_id) AS vs
ORDER BY vs.volume_mount_point;
-- 9 more words

Total number of ways to call default parameter in c#.

Default parameter is a way to pass default value to a method when less argument is passing.

this can be achieve by 4 ways.

I) method overloading… 171 more words


Write a c# program that calculate the length of string without using anyinbuilt function.

string str = “wordcounter”;
str += ‘\0’;
int x = 0;
while (str[x] != ‘\0’)

you could write a loop and increment a counter inside this loop: 32 more words