I want some Moore

Blog about stuff and things and stuff. Mostly about SQL server and .Net
posts - 219, comments - 2287, trackbacks - 33

My Links

Advertisement

News

Hi! My name is 
Mladen Prajdić  I'm from Slovenia and I'm currently working as a .Net (C#) and SQL Server developer.

I also speak at local user group meetings and conferences like SQLBits and NT Conference
Welcome to my blog.
SQL Server MVP

My Books

SQL Server MVP Deep Dives 2
The Red Gate Guide to SQL Server Team based Development Free e-book

My Blog Feed via Email
Follow MladenPrajdic on Twitter


Users Online: who's online

Article Categories

Archives

Post Categories

Cool software

Other Blogs

Other stuff

SQL stuff

October 2007 Blog Posts

C#: Care about Event Memory Leaks with Delegate.GetInvocationList()

UPDATE: After i've been proven wrong in the comments below I have to say this: Go take a read of this article to see how circular references are really handled. While Delegate.GetInvocationList() really is a great and usefull thing and it could be used in clearing up events, there's no need for it since you can do that as easily by simply unsubscribin from the event when you want to dispose your class.   You can read this post on,  but know that this example is WRONG, except for the last part about Observer pattern and WeakEvent pattern. Maybe you should read this post since...

posted @ Wednesday, October 24, 2007 8:30 PM | Feedback (26) | Filed Under [ .Net ]

SQL Server: The one and only locale insensitive date format

Until recently i've been sure that there are 2 date formats that are completly locale insensitive. Those 2 i thought were locale insensitive are yyyy-mm-dd HH:mm:ss.fff and yyyymmdd HH:mm:ss.fff. And i was proven wrong a few days ago!   The only locale insensitive date format is yyyymmdd HH:mm:ss.fff you can easily test this with this script:  DECLARE @t1 table (date DATETIME) SET DATEFORMAT ymd INSERT INTO @t1 ( date ) VALUES ( '2007-10-22 10:15:3.83' ) -- this fails SET DATEFORMAT ymd INSERT INTO @t1 ( date ) VALUES ( '2007-22-10 10:15:3.83' ) SET DATEFORMAT ymd INSERT INTO @t1 ( date ) VALUES ( '20071022 10:15:3.83' ) SET...

posted @ Monday, October 22, 2007 10:21 AM | Feedback (12) | Filed Under [ SQL Server ]

C# : Get current Caret Line and Column in a multiline Windows Forms TextBox

I can't believe these properties aren't already natively implemented. Come on Microsoft... we do live in the year 2007 you know!! I know that you can do this using P/Invoke and SendMessage but i wanted a nice managed way of finding the current line and column of the Caret position in a multiline TextBox.   After a bit of experimenting i've come up with this extended class:   public class TextBoxEx : TextBox { public TextBoxEx() { } public void GoTo(int line, int column) { if (line...

posted @ Friday, October 19, 2007 3:40 PM | Feedback (5) | Filed Under [ .Net ]

SQL Server: Filtering Numeric data from a character based column

Often you can see a request made by people to help them separate data in thier character based columns to numeric and non-numeric part. Most often the answer they get is very simple: Use IsNumeric built in function. But there's a very little known fact about this function though: It DOES NOT behave the way you think it does! You don't believe me? Let's see with an example. How many rows do you think this will return:   DECLARE @t1 TABLE (title varchar(20)) INSERT INTO @t1 SELECT '123d45' UNION ALL SELECT '123e45' UNION ALL SELECT '12 3456' UNION ALL SELECT '123456' UNION ALL SELECT '5532.673' SELECT * FROM ...

posted @ Thursday, October 18, 2007 6:00 PM | Feedback (9) | Filed Under [ SQL Server ]

SQL Server: Why is TRUNCATE TABLE a DDL and not a DML operation and difference from DELETE

First let's look at the difference assuming we want to delete the whole table like truncate does.   Truncate:  - deallocates the data pages in a table and only this deallocation is stored in transaction log  - aquires only table and page locks for the whole table. since no row locks are used less memory is required  (lock is a pure memory object)  - resets identity column if there is one  - removes ALL pages. NO empty pages are left behind in a table  - fast(er)  - doesn't fire delete triggers Delete:  - removes one row at the time and every deleted row is stored in the transaction log  - aquires table and/or page and...

posted @ Wednesday, October 03, 2007 10:20 PM | Feedback (10) | Filed Under [ SQL Server ]

SQL Server: Notify client of progress in a long running process

In long running scripts it's usefull to notify the client of the progress. Here's a simple solution.   Let's create a simple "long running" script: -- this will return all 3 results to the client after 20 seconds (full execution time) SELECT 1 WAITFOR DELAY '00:00:10' SELECT 2 WAITFOR DELAY '00:00:10' SELECT 3   But what if you want to notify the client when each select happened? RAISERROR to the rescue:   SELECT 1 -- flush message to client RAISERROR (N'After 1', -- Message text 10, -- Severity 1) -- State ...

posted @ Monday, October 01, 2007 6:22 PM | Feedback (12) | Filed Under [ SQL Server ]

Powered by:
Powered By Subtext Powered By ASP.NET