Browse by Tags
All Tags »
snippet (RSS)
so i needed to count the lines of a bunch of different filetypes in a folder. i decided to try using linq for this. here's what i came up with. basically a single linq statement =P you can tune the regex to taste. i just said (i think, i'm not...
Stack q = new Stack(); q.Push(argument); while (q.Count > 0) { string d = q.Pop().ToString(); Console.WriteLine(d); foreach (string sd in Directory.GetDirectories(d)) q.Push(sd); }
select case when dbid = 32767 then 'resource' else db_name(dbid) end [db_name] , object_schema_name(objectid,dbid) [schema_name] , object_name(objectid,dbid) [object_name] , sum(usecounts) [executions] , max(max_execution_time) [last_execution_time...
Great useful base diag scripts! Snipped from http://glennberrysqlperformance.spaces.live.com/blog/cns!45041418ECCAA960!893.entry -- SQL Server 2005 Emergency Diagnostic and Performance Queries -- Glenn Berry 3-17-2008 -- Step 1 - Check Task Manager. Are...
select top 10 t.text , s.last_execution_time , * from sys.dm_exec_query_stats s cross apply sys.dm_exec_sql_text(s.sql_handle) t where t.objectid is not null and text like '%procname%' order by s.last_execution_time desc obviously replace procname...
EXEC sp_configure @configname = 'Show Advanced Options', @configvalue = 1 RECONFIGURE WITH OVERRIDE GO EXEC sp_configure @configname = 'clr enabled', @configvalue = 1 RECONFIGURE WITH OVERRIDE GO EXEC sp_configure go
Found something nifty I didn't know about today. create multiple objects in a single using statement. I figured i would include some sample code i use for compression/decompression. I'm using the #ziplib libraries, but you could use any stream...
foreach ( IPAddress ip in Dns .GetHostEntry( Dns .GetHostName()).AddressList) Console .WriteLine(ip.ToString());
string sql = "some sql" ArrayList al = new ArrayList(); using (SqlConnection cn = new SqlConnection(cs)) using (SqlCommand cmd = new SqlCommand(sql, cn)) { cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection...