Search Results
There are 21 item(s) tagged with the keyword "SqlServer".
- Displaying: 1 - 10 of 21
- 1. Sql Server Rank() v/s Dense_rank()
Hello Friends, Some days before I was googling on sql server's system function and I got one site having sql server query puzzle. The site have very interesting puzzle. I got a puzzle during surfing and it is to find out second highest salary of each department and tie salary should also count. There are inbuilt functions in sql server to give rank as per result set. The Rank() function of sql server returns the position of value within a partition of a result set. Rank() function left ...
- By Bharat Patel
- 2. sql server(store procedure) mechanism convert empty string date parameter to initial date(1900-01-01)
Hello Friends, It may you know about it but I would like to share this thing with you. We were working on one of project where we faced issue. we are storing data through sql server store procedure using date parameter. As per our logic, the date parameter has not date value it may be empty string. Whenever date parameter has empty string sql server store initial date(1900-01-01) in the date field. We checked our whole logic to find out how the initial date come if date parameter has an ...
- By Bharat Patel
- 3. SQL Query to list out all Identity column
Hello
Once I want to get the list of all tables which contains the identity column. After some googling finally I got the sql query which return all the tables which has identity column. It will also return column name, the Seed Values, Increment Values and Current Identity Column value of the table.
SELECT TABLE_NAME, c.name AS ColumnName, IDENT_SEED(TABLE_NAME) AS Seed, IDENT_INCR(TABLE_NAME) AS Increment, IDENT_CURRENT(TABLE_NAME) AS Current_Identity FROM INFORMATION_SCHEMA.TABLES INNER JOIN sys.tables t ON t.name = TABLE_NAME INNER JOIN sys.columns c ON t.object_id = c.object_id AND c.is_identity = 1 WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1 AND TABLE_TYPE = 'BASE TABLE'
- 4. Sql Server Query Performance Tuning
Hello Friends,
Try to avoid function (user defined or inbuild) in where condition of sql query as it is always overlook indexing created on tables and taking much longer time to execute in case of table having large number of rows (over million)
Have a look below query. How to avoid date range condition? I hope it may be helpful to you ...
- By Bharat Patel
- 5. Full text option is greyed out in MSSql 2008
Today I was trying to setup fulltext indexing on one of my database table. I have finish with creating fulltext catelog and tried to right click on table to create fulltext index but option was greyed out and there is no way to create index. This is becuse Full-text index was diabled at database leve you can enable it by running below statement. use [mydatabase name] go EXEC sp_fulltext_database 'enable' That's it and refresh table group and option is enable now ...
- 6. anonymous procedure to measure query performance by averaging
Following code can be used to measure query elapsed time by performing multiple runs of the same query and finding the average elapsed time of the query ...
- 7. Reset Identity Column Value
Easiest way to reset the identity column value in MSSQL is to use 'TRUNCATE TABLE' on the table.
This will reset the identity column value.This will work only if the table has no references made by any child ...
- 8. sql server get table list from column name
Hello Friends,
Today, I wanted to list down all table from column name in sql server. Sql server stores all table, column, database or etc in it's own system table. So it's easy to fetch record from it. I have given example below how to list down table list from field name. Copy and paste below code and just pass column name in this query. I hope it is helpful for you and you may like it ...
- By Bharat Patel
- 9. Temporary Table and Table Variables in SQL Server
Temporary Table
The following code demonstrates how to create a temporary table.
Syntax :CREATE TABLE #TempEmployee ( employeeID int, employeeName varchar(100) );
...
- 10. Sql server read excel sheet
Hello Friends, Today we had a requirement to insert data into database from excel sheet. I used POI Utility to read data from excel sheet and it works fine but problem occurs if the recordset has around thousands of record and request time out error occurs. So I was googling for a solution and came across sql server's in-built function ' OPENROWSET '.Using this function we can read and write excel sheet from sql server. Follow the procedure below to read or write excel's data using ...
- By Bharat Patel
- Displaying: 1 - 10 of 21