Friday, November 03, 2006

Creating a Stored Procedure in Microsoft SQL Server Management Studio 2005

A stored procedure is a simple way of grouping Transact-SQL statements into blocks that are easily manageable. It's good for this particular example because we want to execute an INSERT statement and have a value returned to us using the SCOPE_IDENTITY() function, which simply returns the last value inserted into the Identity column (in the same scope).

Here's an example table that we'll be working with:



First, open SQL Server Management Studio and connect to the server with the desired database. From here, go to the Object Explorer -> Databases -> (Database Name) -> Programmability. Right click on 'Stored Procedures' and click on 'New Stored Procedure'. A window with a new SQL Query will come up, it should look something like this:



A lot of the commented parts can be ignored. Let's look at the 'CREATE PROCEDURE' section. This will be the name of your stored procedure. I'll name mine: '[dbo].[RssItem_InsertItem]'. Below this is where the Parameters will be entered. It is important to note that the type of the parameter needs to match the type of the column. If there is any confusion, simply check back to the table that you are working with.

Once we've entered all of the parameters for our columns, we need to create the SQL statement that will be executed. In this example, we use an INSERT statement to populate our table with new values. Notice the '@Identity' parameter and the last line of the SQL statement:
SET @Identity = SCOPE_IDENTITY();
This is the function that we'll use to get the value back, in this case, an identifier that will be used when we call this stored procedure.

The final query should look something like this:



Now, all that's left to do is execute the query. If, for some reason, you get errors, check your query and make sure the parameter types match the column types. Also make sure the SQL statement is correctly formatted.

Once you've done all this, you have your stored procedure created and ready for use.

Wednesday, October 18, 2006

Google Online OS .vs. Microsoft Live

I just recently found an interesting Redmondmag.com article on the current war between Google and Microsoft for internet supremacy. It compares a lot of the new things that the two companies are coming out with to try and dominate the web.

Google Search .vs. Windows Live Search
I personally use google search for almost everything, so making a switch to another search engine seems pointless. I went ahead and checked out the www.live.com search and wasn't terribly impressed. Live.com seems like it's trying to simply mimic the google search, with the pretty Microsoft look. Don't get me wrong, I think Microsoft is a great company, and I wouldn't be surprised if they are at the top for a long time after now. It's a bummer that they couldn't come out with something a little more innovative. Like a breakthrough in search engine technology, maybe previews of the top pages, something like that.

Google GMail .vs. Windows Live Mail
Again, I go with Google here. I made the switch from hotmail (yuck) to Gmail about 3 months ago, and I don't know that I will need to switch again. Tons of space (2GB), integrated chat (Google Talk), and google's great search built in to browse through all of the email in the inbox. I'm interested to see what Microsoft will do to counter this. GMail is just so simple, it will be hard to beat.

Google Talk .vs. Windows Live Messenger
This is where I stick with Microsoft. The Live Messenger is a great interface, and allows contacts with Yahoo! messenger users as well, which is more than convenient. I feel that Microsoft dominates this part of the market, the clientele base is just larger.

I use google talk as well, and although the number of users is much smaller, I still think it's great. Google sticks with simplicity here, like most of all of their interfaces. It's easy to share files, and the call feature is great as well...saves me minutes. I think, with time, Google Talk will be able to compete with Live Messenger.

Google Writely .vs. Microsoft Word?
It's a rough comparison, because currently, Microsoft has no response to Google for this. I have a feeling that Writely is going to blow up quite soon. The ability to have access to all word files from any machine is almost mind blowing. Also, users can collaborate on files from anywhere. If any word processing application was going to compete with Microsoft Word, this would be it.

All in all, it's exciting to think about where the market is going. Google's response to Microsoft is amazing. They're making a lot of the Windows functionality available online, all with the power of Google's search, their plethora of servers, and their pure ingenuity.