NinethSense oWnZ mE!: Praveen’s drawing book

Choose a Topic:

Tue
15
Apr '08

New Data Types in Microsoft SQL Server 2008

There are few new data types introduced in Microsoft SQL Server 2008.

Eg: DATETIME2, DATETIMEOFFSET etc.

Here is a good link for this: http://devlicio.us/blogs/sergio_pereira/archive/2008/04/06/the-new-data-types-in-sql-server-2008.aspx
Mon
10
Mar '08

LINQ, SQLMetal and SqlTac

Here is a good article on LINQ, SQLMetal and SqlTac by Steven R. McCabe.

http://www.simple-talk.com/dotnet/.net-tools/exploring-linq,-sqlmetal-and-sqltac/
Thu
21
Feb '08

SQL Server 2005 Driver for PHP

SQL Server 2005 Driver for PHP CTP (Community Technology Preview - February 2008) is avaialble for download.

Click here to download.



You can visit the SQL Server 2005 Driver for PHP Team Blog at http://blogs.msdn.com/sqlphp/
Tue
29
Jan '08

T-SQL Trigger example

This sample code will copy a field (column) to another field when a new row is inserted or updated.

 
CREATE TRIGGER test /* CHANGE TO ALTER when you edit this TRIGGER */
ON tbltest
FOR INSERT, UPDATE /* Fire this TRIGGER when a row IS INSERTed OR UPDATEd */
AS
BEGIN
                     UPDATE  tblTest  SET  tbltest.testvalue=tbltest.name 
                     FROM INSERTED
                     WHERE inserted.id=tbltest.id
END
 
/* Eg: */
INSERT INTO tblTest (name) VALUES (‘ooooo’) 
 
/* Now CHECK the DATA: */
SELECT *FROM tblTest
Thu
29
Nov '07

My name is 0×5052415645454e in SQL ;)

PRINT CAST(0x5052415645454e AS VARCHAR(7))

It will display ‘PRAVEEN’ :)
Fri
5
Oct '07

OVER and WITH in t-sql

OVER Clause

Determines the partitioning and ordering of the rowset before the associated window function is applied.
URL: http://msdn2.microsoft.com/en-us/library/ms189461.aspx


WITH

Specifies a temporary named result set, known as a common table expression (CTE). URL: http://msdn2.microsoft.com/en-us/library/ms175972.aspx


Below code demonstrates the creation of a temperory table and add a field new field which is an ID field of a sorted column

 
WITH temp_table AS
(
	SELECT *, (ROW_NUMBER() OVER (ORDER BY field_name)) AS row FROM table_name 
)
 
SELECT * FROM temp_table


The above code can also used for paging featuers ;) . Like MySQL’s LIMIT start, length.

 
SELECT * FROM temp_table WHERE row BETWEEN 10 AND 15



Useful, right?

Ref: Inspired from one of my friend Amit Benswal’s blog post
Thu
12
Jul '07

MD5 with t-sql

You can use HashBytes to achieve.
Check this for reference: http://msdn2.microsoft.com/en-us/library/ms174415.aspx

SELECT 
	HashBytes(‘MD5′, ‘Praveen’),
	HashBytes(‘MD5′, ‘PraveeN’),
	‘0xD09C2ECC3DFCDC8C8D921B589097FCB1′,
 
	CASE WHEN convert(int,HashBytes(‘MD5′, ‘PraveeN’)) = 0xD09C2ECC3DFCDC8C8D921B589097FCB1 
	THEN 
		‘Success’ 
	ELSE
		‘Failed’
	END


Note: for MySQL you have MD5() function
Thu
28
Jun '07

MSSQL: Query to display objects in a database

This t-sql query will list names of sql objects and its type:


SELECT
	name,
	CASE WHEN type=‘P’ THEN 
		‘Stored Procedure’
	ELSE
		CASE WHEN type=‘TR’ THEN 
			‘Trigger’ 
			ELSE CASE WHEN type=‘V’ THEN
				‘View’
				ELSE CASE WHEN type=‘U’ THEN
				‘Table’
					ELSE CASE WHEN type=‘FN’ THEN
						‘Function’
						ELSE CASE WHEN type=‘F’ THEN
						‘Foregin Key’
							ELSE CASE WHEN type=‘K’ THEN
							‘Key’
							END
						END
					END
				END
			END
		END
	END
FROM 
	sysObjects 
WHERE 
	type=‘P’ OR type=‘TR’ OR type=‘V’ OR type=‘U’ OR type=‘FN’ OR type=‘F’ OR type=‘K’ 
ORDER BY
	type, name
Wed
23
May '07

Troubleshooting Performance Problems in SQL Server 2005

It is not uncommon to experience the occasional slow down of a SQL Server database. A poorly designed database or a system that is improperly configured for the workload are but several of many possible causes of this type of performance problem. Administrators need to proactively prevent or minimize problems and, when they occur, diagnose the cause and take corrective actions to fix the problem. This paper provides step-by-step guidelines for diagnosing and troubleshooting common performance problems by using publicly available tools such as SQL Server Profiler, System Monitor, and the new Dynamic Management Views in SQL Server 2005.


Here is the link: http://www.microsoft.com/technet/prodtechnol/sql/2005/tsprfprb.mspx
Tue
22
May '07

Choosing the right programming language

My students used to ask me “which programming language is the best?” and “which programming language I must learn?”. But the truth is – one cannot give an accurate answer for this. If somebody answers to this question simply - like C++ or Java, I will say he is a frog living inside a well. He may be giving this answer from his experience and knowledge, which is very less.


Check my latest article at : http://ninethsense.com/content/view/51/55/
The CodeProject Microsoft Developer Network Official ASP.NET Forums Microsoft .NET Framework Community Microsoft Most Valuable Professional Kidoos forums Microsoft Visual Studio Developer Home Professional Information Technology Solutions Microsoft Research Home Trivandrum Microsoft Users Group Community Website