Tag - SQL

How to use SQL Membership Provider in ASP.NET

The ASP.NET membership feature provides secure credential storage for application users. We will use the following: Web Page Named Login.aspx and another Web Page named CreateUser.aspxLogin Control.Create User Wizard Control. Steps: 1- Configure Forms Authentication in Web.config File To configure forms authentication, set the <authentication> element's mode attribute to "Forms" and then configure your application's Web.config file as shown...

How to select from Datatable in C#.NET

DataTable Object has a Select Method which acts like Where in SQL Server. So if you want to write filter query you write the column name directly without Where and the filter expression you want. I made a simple example that creates a DataTable and fill it with some data and use Select method: DataTable dt...

How to get year, month and say out of SQL Date in SQL Server

Let is say that we have the following Date 2007-04-05 10:13:14.109 and we want to get Year, Month and Day out of this date. There is a function named DATEPART() that can be used to archive this. DECLARE @MyDate AS DATETIME SET @MyDate = '2007-04-05 10:13:14.109' SELECT DATEPART(DAY, @MyDate) AS MyDay, DATEPART(MONTH, @MyDate) AS MyMonth, DATEPART(YEAR, @MyDate) AS MyYear The result...

Difference between inner and outer join in SQL

Joins are used to combine the data from two tables, with the result being a new, temporary table.The temporary table is created based on column(s) that the two tables share, which represent meaningful column(s) of comparison.The goal is to extract meaningful data from the resulting temporary table.Joins are performed based on something called a...

How to check SQL Server database is exists using C#.NET

The following method using sys. schema and views such as sys.databases and sys.tables.As we know that the old style sysobjects and sysdatabases and those catalog views have been deprecated since SQL Server. private static bool CheckDatabaseExists(string connectionString, string databaseName) { string sqlQuery; bool result = false; try { ...

Prevent Saving Changes That Require Table Re-creation SQL Server

I was modifying an existing table using SQL Server Management Studio, but I got this error message on saving: Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option...

How to Dynamically Select rows in SQL Server

If you want to restrict other developers from using your Stored Procedures that returns a huge amount of data which affects server performance and Application Performance weather it is a Windows or Web Application. You can use the following idea when you create Stored Procedures: -- ============================================= -- Author: Amr...

XML Data and Document Storage in SQL Server

XML is a platform-independent data representation format based originally on SGML. Since its popularization, it is becoming used as a data storage format. It has its own type system, based on the XML Schema Definition language (XSD). Both XML and XSD are W3C standards at the Recommendation level. An XML schema defines the format...

SQL Server as a Runtime Host

If you are a SQL Server developer or database administrator, you might just be inclined to use the new Common Language Runtime (CLR) hosting feature to write stored procedures in C# or VB.NET without knowing how it works. But you should care. SQL Server is an enterprise application, perhaps one of the most important...