Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Everything / database / SQL-Server / SQL-Server-2005

SQL-Server-2005

SQL-Server-2005

Great Reads

by Suresh Dasari's
Auto Generate Code (CRUD) for 3 Layered architecture (Entity, Data Access & Business Layer) with Stored Procedures based on table design.
by Rick Bassham
How to use the SqlChangeMonitor with the new MemoryCache class in .NET 4.0.
by John Kenedy S.Kom
This project enables developer to create a setup package that automatically installs SQL 2005 Express and restores database to it
by Omar Al Zabir
Learn about 13 production disasters that can bring down your business

Latest Articles

by Suresh Dasari's
Auto Generate Code (CRUD) for 3 Layered architecture (Entity, Data Access & Business Layer) with Stored Procedures based on table design.
by Rick Bassham
How to use the SqlChangeMonitor with the new MemoryCache class in .NET 4.0.
by John Kenedy S.Kom
This project enables developer to create a setup package that automatically installs SQL 2005 Express and restores database to it
by Omar Al Zabir
Learn about 13 production disasters that can bring down your business

All Articles

Sort by Score

SQL-Server-2005 

by Suresh Dasari's
Auto Generate Code (CRUD) for 3 Layered architecture (Entity, Data Access & Business Layer) with Stored Procedures based on table design.
by Md. Marufuzzaman
A simple tip/trick to get rows on n’th maximum number from a table
by Md. Marufuzzaman
A simple example of Microsoft SQL Server Pad String
by Rajat-Indiandotnet
A unique feature of SQL SERVER Loop with Go statement
by Jobless Creature
HH:MM Time format addition
by Shahriar Iqbal Chowdhury/Galib
Hi,Here is an alternative for your solutionSELECT CAST(DATEADD(MILLISECOND,SUM(DATEDIFF(MILLISECOND,0,CAST(TMP.TotalTime as DATETIME))),0) as TIME)FROM( SELECT CAST(timeduration AS TIME) TotalTime FROM mytable) TMP
by abdul sami
select aday, code, convert(varchar(5), min(atime), (108))MinTime, convert(varchar(5), max(atime),(108)) MaxTime from testgroup by aday,codeorder by aday asc
by Wendelius
Or simply:exec msdb..sp_help_jobsp_help_job (Transact-SQL)[^]
by SatyLepide
By analyzing log-in attempts on SQL server, admins can build the complete picture out of the sequence of events that led to compliance failure or unauthorized access.
by Hiren solanki
Building hirarchy in the sense of hirarchy of manager, employee though both are an employee of an enterprise but both are related or depend on hierarchical level.
by Hernán Hegykozi
This tip explains how to calculate the Check Digit Vertical (CDV) and Horizontal (CDH) by SQL Server.
by Sunasara Imdadhusen
Clear the transaction Log if you are facing a low disk space
by thatraja
By this way tooHow to Shrink SQL Server database log files?[^]
by sx2008
The root cause why the transaction log file grows so big is the wrong recovery model.The recovery model is set to full by default.99 percent of all SQL Servers never make use of this model because there is no backup of the transaction log file.So the great majority of all databases should...
by Levente Kupás
CLR-addon for T-SQL DATE transformation and Split-String
by Jobless Creature
CTE To find all the related nodes in a hierarcy
by Ramanujam Shankar
Using COALESCE function - concatenate many rows into a single text string output in SQL Server.
by e-Lopes
How to concatenate many rows into a single text string using SQL Server 2008.
by Sanjay K. Gupta
How to concatenate many rows into a single text string using SQL Server 2008
by PIEBALDconsult
See also Stupid CTE tricks -- string concatenation[^]
by NightWizzard
Handling for hex expressions and the trailing '}'
by Anurag Gandhi
A Query to copy an individual table data between databases
by Mubin M. Shaikh
Create time dimension with 24 hour plus values and time buckets in your data warehouse
by Aadhar Joshi
Creating job in sql server which automates taking backup of all stored procedures and functions in physical drive.
by SuhasHaridas
Create Linq to SQL connection with select, insert, delete, update
by Diluka Wittahachchige
Creating SQL Server database project use in Visual Studio 2012 and maintain versions use in TFS
by Sreedhar Puligundla
Simple steps to create SQL joins by using SQL Server 2008 Management Studio
by Matthew Taylor
How to remove Microsoft SQL Server triggers associated with a custom schema.
by Bob Crowley
How to use a CASE statement in ORDER BY to avoid dynamic SQL
by ss9o9o9o
Transferring backup files from a remote SQL Server and Dynamic SQL Connection with Restore utility.
by kennysun
encrypt all stored procedures in SQL server with powershell
by jroughgarden
This is an alternative for "Encrypting all Stored Procedures of a Database".
by qadirv
Quick C# console application to encrypt all your database stored procedures
by Nandakishore G N
Example For Gridview RowCommand Event
by Ramanujam Shankar
Find missing date periods from a table.
by Pranay Rana
Problem : - During project development I got the requirement that I have to modified the column name of the table which is used in the no of procedure i.e i have to found all procedure related to that table and modify it For the above problem following are the solution that i used First ...
by Nelson Kosta Souto
Find text in Stored Procedures, View, Trigger, and Function.
by Rishikesh_Singh
Generate Insert script to extract data
by Sunasara Imdadhusen
SQL Server 2005 : Generate Script with Data from Database – Database Publishing Wizard
by tarun_j200
SSMS also provides the option to generate SQL script file which contains both schema and data.Right click the database and select Generate Scripts under Tasks Menu.Click Set Scripting Options on the left hand menu (in SQL Server 2008 R2) then click Advanced button, there is an option under...
by Harsh Gandhi
Generate XML Using FOR XML ; Difference between different modes (AUTO, RAW, PATH, EXPLICIT) of FOR XML to generate XML in SQL Server
by Tharaka MTR
This article describes the easiest way to create and process delimited row using SQL XQuery.
by Md. Marufuzzaman
Get accurate age by date using MS SQL Server
by rajivlipu
select days_of_month=day(dateadd(mm,-1,'12-feb-2010'),-1) :laugh:
by g_p_l
@dt is a datetime valuederive the first of this month, add a month to itthen subtract 1 day to get the last day of this monthselect days_of_month=day( dateadd(d,-1, dateadd(m,1, dateadd(d,1-day(@dt), @dt) ) ) )
by Md. Marufuzzaman
This is a very simple use of SQL Server global variables. Microsoft SQL Server provides a massive number of global variables, which are very effective to use in our regular Transact-SQL. Global variables represent a special type of variable. The server always maintain the values of these...
by Dhol Gaurav
Get Tables List With Its Dependent Tables Names
by Mahmud Hasan
How to use variable in SELECT TOP SQL command
by RahulAJoshi
Grouping dynamically on different columns in single query
by kiran dangar
Understrading sys.objectsSys.objects is a system VIEW in SQL Server 2005, for each SQL database there is a separate sys.object view which gets stored within databse itself.Using Sys.objects returns list of all database objects and its types, type can be either of given below:DB OBJECT...
by VDmitrovsky
1) You cann't drop any object in schemas other than dbo, so you MUST use sys.schemas system view properly.2) You cann't drop tables even in dbo schema if they are referenced by other ones, not dropped so far. Drop all FKs before tables.dva
by kiran dangar
For Ravi LVS,The way you have suggested to Empty the database by just deleting and recreating it, is not at all smarter way when you are about to empty a remote database located on live database server, There are times when you don't hold such rights of deleting database on Live...
by Rajat-Indiandotnet
Find column or Text in entire stored procedure
by chetan dudhagara
How to Protect from SQL Injection in PhP based website
by Wendelius
This tip describes how to delete duplicate rows from a table that doesn't have a key.
by Costica U
Here is another solution:IF OBJECT_ID( 'tempdb..#TestTable' ) IS NOT NULL BEGIN DROP TABLE #TestTable ENDCREATE TABLE #TestTable ( Column1 varchar(1), Column2 int )INSERT INTO #TestTable VALUES ('A', 1);INSERT INTO #TestTable VALUES ('A', 1); --...
by Sandesh M Patil
How to search a column name within all tables of a database and how to search stored procedures containing a particular text
by SA - Hibbert
Return all records between two dates that include time in SQL.
by Abhishek Sur
It is a common issue of many of the guys on how we can fetch a record based on its record number. It is really easy to get first 10 records usingSELECT TOP 10 * FROM EMPBut when we want to fetch records in such a way say I need to fetch record from 40 to 50. This comes very handy when...
by Wonde Tadesse
This tip/trick helps to set a default value for blob data type such as Image, VarBinary.
by Rohan Kishor Garud
RoundhousE (RH) is a database migrations engine that uses plain old SQL Scripts to transition a database from one version to another.
by Md. Marufuzzaman
This tip shows you an easy way to split Microsoft SQL Server table row data.
by ManojKumar19
Update row column with another row column in same table SQL only if it is null.
by Arvind Singh Baghel
Import CSV or txt File Into SQL Server Using Bulk Insert.
by Mr. Joydeep Das
What the effects of Ordering in Index
by Mehul M Thakkar
I was facing the problem of inserting a default value on single column table and I have achieved via this way.insert into > default valuesAlso this could be used for many columns in a table defining with default constraints.ThanksMehul Thakkar
by Ravi Tuvar
Installing SQL Server 2005 and 2008 in the same computer.
by Paw Jershauge
MS SQL system views, mapped over version.
by thatraja
SELECT TOP 1 salaryFROM (SELECT DISTINCT TOP n salaryFROM employeeORDER BY salary DESC) aORDER BY salarywhere n > 1SQL SERVER – Find Nth Highest Salary of Employee – Query to Retrieve the Nth Maximum value[^]
by Costica U
The original solution has some issues. Check the following script:IF OBJECT_ID('tempdb..#salary') IS NOT NULL BEGIN DROP TABLE #salary ENDCREATE TABLE #salary ( Salary INT )INSERT INTO #salary(Salary) VALUES(5) -- 1INSERT INTO #salary(Salary)...
by Pranay Rana
Getting a SQL Server RowCount Without doing a Table Scan
by Durgesh Swarnkar
Getting the count of records in a particular column.
by RaviRanjanKr
A tip enable you to learn how to use Column_Index instead of Column Name with Order by clause
by Sifiso W Ndlovu
This tip illustrates a workaround to SQL Server pivoting on variable character data types.
by Gene R. Browning
Generate random dates (and times if you like) for your test data environment.
by Md. Marufuzzaman
How easy to read a file without using of the seven extended stored procedures.
by pankaj_254768
Shows how to read an Excel file using SQL query commands from SQL Server
by thatraja
The below query can be used to get the record count of all tables in the current database.
by Md. Marufuzzaman
This is good... You can also consider this link.[^]
by tarun_j200
Also use either this one:SELECT OBJECT_NAME(SYSINDEXES.id), SYSINDEXES.rowcntFROM SYSINDEXES INNER JOIN SYSOBJECTS ON SYSINDEXES.id = SYSOBJECTS.idWHERE SYSINDEXES.indid < 2 AND SYSOBJECTS.xtype = 'U'or this one:SELECT OBJECT_NAME(id),rowcnt FROM SYSINDEXES WHERE...
by Pranay Rana
Number of different ways to get total number of rows from tables
by Graham Cottle
Sometimes it is necessary to have the schema name included as well. I concatenate with the table name for my convenience, but it is not vital to do so.SELECT sys.sysindexes.rows, sys.schemas.name + '.' + sys.objects.nameFROM sys.objectsINNER JOIN sys.schemasON ...
by Tecfield
This tip shows how to rename a database and its MDF and LDF files in SQL Server.
by Yogesh Gulve
Return Comma Separated String using SQL
by sachin bankar
How to use the result set from a Stored Procedure in a Select statement.
by Luca Astolfi
User defined procedure for make an HTML table from T-SQL Select statment
by Jobless Creature
Masking selected characters in SQL, hiding few characters
by Saral S Stalin
Explains how to run a script with higher priority to avoid it getting terminated in a deadlock situation.
by DecodedSolutions.co.uk
This is a simple article describing how to create an add an outlook appointment to your MS Outlook Calender.
by headshot9x
How to create ShoppingCart using Gridview in asp.net with code VB
by Kale Yogesh
SHRINKFILE and TRUNCATE Log File in SQL Server 2008
by SERokon
Exclude Column from SELECT * statement
by bmckuhen
How to get a quick list of all DBs using SMO
by Anurag Gandhi
I have gone through a lot of examples to sort alpha numeric data in sql. Here is my way:
by Gauri Chodanker
SQL function in SQL
by Robby Tendean
How to do SQL atomic operations on UPDATE and DELETE syntax.
by Pranay Rana
How to use Group By clause when joining to table Let's consider one scenario where I have two table employees (contains employee detail) and sales (contains infomation about sales done by employee).Structure of...
by mkader
SQL scripts to insert File to BLOB field and export BLOB to File
by aasim abdullah
Backup and then restore of a database is a normal job for developers and DBAs. This script will be helpfull to findout, from which path, and which backup file a database was restored.
by Dathuraj Pasarge
Know whether your databases are backed up successfully in the last 24 hours or not !!!
by Atul_Kapoor
Perform SQL Server Instance health check simultaneously on more than one server using Powershell
by aasim abdullah
A stored procedure can be called from another stored procedure as nested stored procedure. How to get a list of these stored procedures with their nested one
by Surender Singh (CodeToastDev)
Custom StringPadding functions for SQL Server
by Sivaraman Dhamodharan
How do you use the Template explorer and assign parameter values.
by aasim abdullah
Automatic query execution at every instance startup.
by aasim abdullah
You have place indexes but still queries are slow... are you facing bookmark lookup problem ???
by aasim abdullah
How to use DELETED and INSERTED virtual tables to capture data change in result of any INSERT, UPDATE or DELETE statement.
by aasim abdullah
A simple query to get all databases size on a given instance.
by aasim abdullah
Get all indexes list in detail, with their involved columns
by aasim abdullah
How do you know, if someone disabled your job at production database server. Who is the calprit. How to send a mail alert for this change ??
by aasim abdullah
Restore failure from Enterprise to Standard edition in SQL Server.
by aasim abdullah
The TOP clause is commonly used to get the top required rows from a result set. The beauty of this clause is that it can be used with the WITH TIES clause to retrieve all similar rows to a base result set.
by smirson
This is an alternative for "String splitting/tokenizing using T-SQL user defined function."
by Irfan Baig
String splitting/tokenizing using T-SQL user defined function.
by Hajo Messner
There is a little inconsistence in this function, because the @Tokens Elements and the @Delimiter parameter are of data type NVARCHAR (=Unicode) while the @String parameter is of data type VARCHAR (=ANSI). If the @String parameter can be Unicode, it must be declared as NVARCHAR. If the @String...
by BharatRamV
Finds the Best Table for a given set of columns
by Talking Dotnet
The SELECT TOP N query always returns exactly N records, and randomly drops any record that have the same value as the last record in the group.SELECT TOP 5 price, Booktitle FROM BookTitles ORDER BY price DESCThis query will give 5 records from table BookTitles in descending order by price. ProblemS
by salchichurria
Triki game created in SQL Server with triggers.
by Paul M Simpson
Expanding a string by inserting alternating single spaces between characters
by pankajupadhyay29
A nice way to get aggregated value without group by
by chetan virkar
Uploading Zip File in ASP.NET
by John Gathogo
Catastrophic results associated with unqualified use of columns belonging to tables referenced on main query in a subquery
by rajeshitpro
Union All,Select
by pankajupadhyay29
Nice and fast way for reporting
by Feleke Feyissa
select * from(SELECT l.Prepared_Date as Prepared_Date , m.Material_Code as Material_Code ,n.Name as Name,n.Description as Description , m.Quantity as Quantity,n.Unit_Of_Measure as Unit_Of_Measure , m.Status as Status...
by Kannan K R
select ExDate, SUM(case when Dept='A' then expense else 0 end)[Store A Expense],SUM(case when Dept='B' then expense else 0 end)[Store B Expense],SUM(case when Dept='C' then expense else 0 end)[Store C Expense]from expenseTable where Dept in ('A','B','C') group by ExDate
by Indrajeet Sutar
While using stored procedures, we need to pass SQL parameteres to those stored procedures. When there are large numbers of parameters then it is become boring task or tedious job to debug and check what values passed with. Here I have created a function that will check the values passed to...
by alifaraze
writing error in a text file is very easy but writing error from a custom assembly in reporting services requires permissions