Programming, SQL, SQL Server 2008, SQL Server 2000, SQL Server 2005, Transact-SQL, tSQL, SQL Tips, Database, SQL Server 2012

TSQL Search for the Last Record in a Group

In this article I’ll show how to get the most recent record for a group of records in a SQL Server table. There are a number of ways to do this including CTEs and nested subqueries. Since nested subqueries are the most widely supported across the different versions of SQL Server, I consider them the most robust/straightforward way to get the job done, so in this article I will show you how to solve this problem using a nested subquery in either your WHERE or your FROM clause.

At the end of this article I’ll give the full working example Pet shop table and query that you can copy and paste into a SQL Server Management Studio (SSMS) session to try out the code for yourself.

If you find this article useful, be sure to check out my other SQL Server related articles for more tips.

Continue reading “TSQL Search for the Last Record in a Group”

Programming, Software, SQL, SQL Server 2005, SQL Server 2008, SQL Server 2012, SQL Tips, System Objects, Transact-SQL, tSQL

Steps Restore a SQL Server Database into a New Database and Rename it

If you want to create a working backup of one of your production databases that you can use without jeopardizing the production data, you’ll need to copy the database in its entirety to a new name. In this article I’ll review the steps you need to use to do this (in SQL Server Management Studio 2014).
Also, if you find this article helpful, feel free to check out the other articles on my site covering various SQL examples at:

Continue reading “Steps Restore a SQL Server Database into a New Database and Rename it”

.Net, ASP.NET, C#, Database, Programming, Security, SQL, VB.NET, Web Development, WebForms

Example of Encrypting and Decrypting a String into a SQL Table Using ASP.NET

I’ve put together this article because even after a lot of searching, I wasn’t able to find a simple, working example of how to encrypt and then decrypt a string that you are saving in your database in ASP.Net. Sure, there are some partial examples, but partial code usually doesn’t answer the question properly. Added to that, a lot of examples are out there that plain don’t work, confusing the issue and wasting a lot of time. So in this article I’ll give an example of a fully working test Web page that saves an encrypted string to a SQL Server database table, and that also shows the decrypted field back to the user.

Continue reading “Example of Encrypting and Decrypting a String into a SQL Table Using ASP.NET”