Home / Archive by category 'Programming'

| RSS

Create T-SQL CASE Statements With LINQ To SQL

I was recently helping Nosh with a LINQ To SQL query where he wanted the resulting T-SQL query to have CASE statements. Having CASE statements in T-SQL queries is a common scenario but how do we it in LINQ To SQL .After some investigation I found the solution which I am presenting here using an [...]

[ More ] March 24th, 2009 | 1 Comment | Posted in Programming |

SQL Server – sp_spaceused Use The Right Way

To find out the space used by a table we can use sp_spaceused procedure. Most of the times sp_spaceused will give correct information. Why do I say most of the time? Well consider this example. I just inserted a large amount of data in Orders table in Northwind database and ran sp_spaceused.
EXEC sp_spaceused ‘Orders’
which returns [...]

[ More ] March 19th, 2009 | No Comments | Posted in Programming |

Download Entire SharePoint 2007 Technical Library In CHM

The title says it all.
Here is the Link.

[ More ] March 19th, 2009 | No Comments | Posted in Programming |

SQL Server 2008 – 2 Ways To Get Object Id Of A Database Object

Every object in SQL Server database has an Object Id which is used extensively by SQL Server for most operations. There are times when we would like to know what the object ID is for a particular object. In this example I will show you two ways to retrieve Object Id. My examples will retrieve [...]

[ More ] March 18th, 2009 | No Comments | Posted in Programming |

Walkthrough – Generate Test Data With Red Gate SQL Data Generator

In this walkthrough I will show you how to use Red Gate SQL Data Generator to generate test data for a database. While writing software which interacts with a database developers often write scripts to insert some data. Usually this data is not big enough to find performance bottlenecks and/or issues with presenting data on [...]

[ More ] March 18th, 2009 | No Comments | Posted in Programming |

SQL Server 2008 – Find Default Constraints On a Table Using T-SQL

This script returns all default constraints on a table in a SQL Server 2008 database. It gives me the name and definition of the constraints on Person.Address table in Adventure Works database. You can substitute the table name with any other table to get the constraints for that table.
SELECT [name],
[...]

[ More ] March 12th, 2009 | No Comments | Posted in Programming |

Installing Oracle SOA Suite On Windows XP

In this post I will document my experience of installing Oracle SOA Suite on Windows XP. No I am not switching and I’m still a Microsoft developer by heart. But I do feel that for me to improve my craft I must also understand how things are done in other camps such as Oracle, SUN, [...]

[ More ] March 12th, 2009 | 3 Comments | Posted in Programming |

Get Processor Information In .NET Using C#

.NET Framework provides classes which give information about the machine on which code is executed. One Such class is System.Environment which gives us things like Machine Name, OS Version and much more. I recently had a requirement to programmatically detect the number of Processors on a machine. I thought this was a simple enough task. [...]

[ More ] March 9th, 2009 | 1 Comment | Posted in Programming |

SharePoint Installation Failed To Create Sample Data

This one always gets me off guard so I’m posting this here for more than anything else to remind me. The issue occurs when you configure your MOSS environment which is normally done after installing MOSS. The issue is that while inserting sample data the wizard throws an error which says “Failed to create sample [...]

[ More ] March 5th, 2009 | 7 Comments | Posted in Programming |

SQL Server 2008 – Find If A Database Is Offline With T-SQL

In SQL Server 2008 you can find if a database is online of offline by querying databases system view. A simple query such as this one gives me a list of all databases on my server and the second column shows if the database is online or offline.

SELECT Name, state_desc
FROM sys.databases

On my server [...]

[ More ] March 3rd, 2009 | No Comments | Posted in Programming |

Bypass Windows Password Requirements For SQL Login

SQL Server by default follows Windows password policy requirements for SQL Server Login accounts. This forces you to follow the same policy for SQL Server logins as you would for windows logins and this is a good thing. But sometimes you want to bypass that validation maybe to get a test login in place. You [...]

[ More ] March 2nd, 2009 | 2 Comments | Posted in Programming |

Check If A Login Exists In SQL Server 2008

If you are creating a SQL Server login using a script then it is advisable to check if the login you are creating already exists. If you do not do this then SQL Server will throw an error. For example if I execute this statement when a login with name test_user already exists, I will [...]

[ More ] March 2nd, 2009 | No Comments | Posted in Programming |