SQL Server 2012 introduced the new feature called AlwaysOn. AlwaysOn provides High Availability & Disaster Recovery alternative to Database Mirroring. What is Database Mirroring? Database Mirroring is a technique to increase High Availability of database. The topology consists of three server roles. Witness Server Principal Server Mirror Server Transaction Logs will be synchronized from Principal […]
The Enterprise Management studio provides an option to shrink the database. Step 1: Open Enterprise Management Studio (i am using sql server 2008) and select database, right click and choose Tasks>Shrink Step 2: In the appearing dialogue press Ok to start the shrink process.
I would like to take a moment to explain the following problem I am facing: I do have a table named Equity which contains the company name and the current PE Ratio. The PE Ratio will be updated daily or weekly based on the wish of user through a web application in ASP.NET. When the […]
Some useful sqls I am sharing here. Description Sql Get Row Number of any table SELECT ROW_NUMBER() OVER (ORDER BY Name ASC) AS ROWID, * FROM TableX Delete Duplicate Records WITH CTE (Col1,Col2, DuplicateCount) AS ( SELECT Col1,Col2, ROW_NUMBER() OVER(PARTITION BY Col1,Col2 ORDER BY Col1,Col2) AS DuplicateCount FROM Table1 ) DELETE FROM CTE WHERE DuplicateCount […]
We can use the sys.tables and sys.objects to find metadata of tables and columns. Display all User Tables select * from sys.tables – displays all user tables Display all Columns in a Table select * from sys.columns where object_id in (select object_id from sys.tables where name=’MyTable)
For a long time I was wondering about why the xml type is needed in sql server. Following are a few number of advantages on using xml column types which I found implemented in industry. We can store entire xml content in the column and later query on the xml tags We can store application […]