Some time while reviewing a log file, especially any error log of something like that, we need to find you that how much is error rate per minute, the following piece of code is used for retrieving information for every minute. Let's create an Error log table. CREATE TABLE Errorlog ( logid INT identity(1, 1) … Continue reading To get number of records per minutes, means gouping on minutes in a given timeframe.
Category: Scripts
Which table is having maximum number of colums
The following script can be used to fetch the tables having maximum number of columns in sql server tables. SELECT st.NAME 'Table Name' ,count(sc.NAME) AS 'No of columns' FROM sys.columns sc WITH (NOLOCK) INNER JOIN sys.tables st WITH (NOLOCK) ON sc.object_id = st.object_id GROUP BY st.NAME ORDER BY 'No of columns' DESC Thanks Manish … Continue reading Which table is having maximum number of colums
Details of Primary Keys, Foreign Keys, Unique Keys and Indexes.
The following script can be use to get the list of all Primary Key, Foreign Key and Unique Key. The following script can be used to get the list of all Indexes. Thanks Manish
Data Dictionary
The following script is used to create Data Dictionary for all tables. However these above script can be modified to get details of any specific schema. Thanks Manish
Results as comma separated
Many times we needed to have some values as comma separated , the following are few scenarios. Single Table Following shall be output Having two table and needed joins Following shall be output The following is other way of doing without STUFF function and with Substring. Data selected from a single table (Table2) … Continue reading Results as comma separated
Delete duplicate records
The following are the ways to delete duplicate rows from a table, and its purely depends upon your environment, its recommend to first try it on development server and then move ahead to production environment. Using group by clause and move the records to another table, truncate original and move records back to original. There … Continue reading Delete duplicate records