Encrypt Password in SQL

Hello folks,

Today we will see how we can encrypt password before saving into database table.

There are many ways to implement this feature like defining Asymmetric keys and using that into table/sp or use some hash algo to encrypt password etc but we will add some complexity into encryption stuff.

Objective:  Our goal is to generate very complex and encrypted password which can’t be hacked (not even by database guys using sql injection etc).

Solution:

Step 1: Create a table that will hold username, password and other details. See below sample. Continue reading

Advertisements

Important Sql Queries

Introduction: In this article i am going to give some of very useful SQL Queries that are required to us in our day to day programming life.
1. Get current Database Name:  Select DB_NAME()
2. Get Details Of All Databases Present In SQL Server: Select * from sys.databases
3. Rename A Database: Exec sp_renamedb ‘oldDatabaseName’ , ‘newDatabaseName’ Continue reading

Optimization Of Stored Procedure In SQL Server

This article describes that how we can optimize the Stored Procedures so that we can get better performance while our application is talking to database. I am enlisting some of the points from my personal experience.

 

1)    Always Use Fully Qualified Name For All Database Objects:

While working with stored procedure we need to pass name of database objects (table, view, function, other stored procedure(s) etc.) several times. I recommend every developer to use fully qualified object names instead of using only object name. There is a very strong reason behind this recommendation.

  • SQL server always has to find supplied database object name from sys object that took some millisecond of processing time and consumption of CPU resources. And if, we pass fully qualified name then that processing time and CPU resource consumption to search the object from sys objects get reduced to significant amount.
  • Another reason behind the scene is it helps SQL Server to directly finding the Complied Cache Plan if available instead of searching the objects in other possible schema. This process of searching and deciding a schema for a database object leads to COMPILE lock on stored procedure which decreases the performance of a stored procedure.
Continue reading

Database Concept

What is RDBMS?
Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.

What is normalization?
Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships. Continue reading

The Entity Framework and ASP.NET – Getting Started Part 7

Using Stored Procedures

In the previous tutorial you implemented a table-per-hierarchy inheritance pattern. This tutorial will show you how to use stored procedures to gain more control over database access.

The Entity Framework lets you specify that it should use stored procedures for database access. For any entity type, you can specify a stored procedure to use for creating, updating, or deleting entities of that type. Then in the data model you can add references to stored procedures that you can use to perform tasks such as retrieving sets of entities. Continue reading