Friday, July 5, 2013
Thursday, September 22, 2011
How to Monitor a Directory for Changes in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplicationTest
{
class Program
{
static void Main(string[] args)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"c:\";
watcher.Renamed += new RenamedEventHandler(watcher_Renamed);
watcher.EnableRaisingEvents = true;
Console.ReadLine();
}
static void watcher_Renamed(object sender, RenamedEventArgs e)
{
Console.WriteLine("Renamed from {0} to {1}", e.OldFullPath, e.FullPath);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplicationTest
{
class Program
{
static void Main(string[] args)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"c:\";
watcher.Renamed += new RenamedEventHandler(watcher_Renamed);
watcher.EnableRaisingEvents = true;
Console.ReadLine();
}
static void watcher_Renamed(object sender, RenamedEventArgs e)
{
Console.WriteLine("Renamed from {0} to {1}", e.OldFullPath, e.FullPath);
}
}
}
Sunday, September 4, 2011
Find a procedures having a particular text to be searched in.
SELECT ob.id,ob.name
FROM sys.sysobjects AS ob INNER JOIN
sys.syscomments AS comm ON ob.id = comm.id
where ob.xtype='P' and ob.uid=1 and comm.text like '%(list%'
FROM sys.sysobjects AS ob INNER JOIN
sys.syscomments AS comm ON ob.id = comm.id
where ob.xtype='P' and ob.uid=1 and comm.text like '%(list%'
Object counts in SQL server Database
select
case xtype
when 'D' then 'Default Constraint'
when 'F' then 'Foreign Key Constraint'
when 'FN' then 'Function(s)'
when 'P' then 'Stored Procedure'
when 'PK' then 'Primary Key Constraint'
when 'SQ' then 'SQ'
when 'U' then 'User defined table'
when 'UQ' then 'Unique Constraint'
Else 'Other'
end Object_nm,
count(1) cnt
from dbo.sysobjects
where UID=1
group by xtype order by cnt desc
case xtype
when 'D' then 'Default Constraint'
when 'F' then 'Foreign Key Constraint'
when 'FN' then 'Function(s)'
when 'P' then 'Stored Procedure'
when 'PK' then 'Primary Key Constraint'
when 'SQ' then 'SQ'
when 'U' then 'User defined table'
when 'UQ' then 'Unique Constraint'
Else 'Other'
end Object_nm,
count(1) cnt
from dbo.sysobjects
where UID=1
group by xtype order by cnt desc
Tuesday, April 28, 2009
How to determine which version of SQL Server 2005 is running
To determine which version of Microsoft SQL Server 2005 is running, connect to SQL Server 2005 by using SQL Server Management Studio, and then run the following Transact-SQL statement.
SELECT SERVERPROPERTY('productversion'),Source :: http://support.microsoft.com/kb/321185
SERVERPROPERTY ('productlevel'),
SERVERPROPERTY ('edition')
Thursday, October 23, 2008
Shutdown Keyword in SQL Server 2005
The Shutdown a running Microsoft SQL Server service.
|
Get List of Tables in a Database - Query INFORMATION_SCHEMA.Tables - ADO.NET
string connectionString = "...";
DataTable tables = new DataTable("Tables");
using (SqlConnection connection =
new SqlConnection(connectionString))
{
SqlCommand command = connection.CreateCommand();
command.CommandText = "select table_name as Name from
INFORMATION_SCHEMA.Tables where TABLE_TYPE =
'BASE TABLE'";
connection.Open();
tables.Load(command.ExecuteReader(
CommandBehavior.CloseConnection));
}
Subscribe to:
Posts (Atom)