
Problem solve
Get help with specific problems with your technologies, process and projects.
SQL Transact SQL T SQL
SQL Server batch rules
SQL Server batch rules are explained in this tip by contributor Baya Pavliashvili who warns of potential failures if certain guidelines aren't followed when grouping T-SQL commands into batches. Continue Reading
A sample query for students with most classes
Expert Adam Machanic offers a sample query to find the names of the students enrolled in the largest number of classes. Continue Reading
What is the difference between T-SQL and "normal" SQL?
-
Should I switch databases inside the procedure?
Rather than use a command to switch from one database to another database in a procedure, expert Greg Low offers a better alternative. Continue Reading
Getting data from two servers using the same query
Greg Low explains how to use the same query to pick up data from two linked servers. Continue Reading
Creating a script for row selection
Development expert Greg Low offers a script to select a row with the greater date, where item_key and pack_key are equal.Continue Reading
Querying current and previous outstanding reserves
Greg Low offers help writing a query that gives both the current outstanding reserve and the prior outstanding reserve.Continue Reading
Sum aggregate operation won't take varchar data type
The sum or average aggregate operation cannot take a varchar data type as an argument. So how can this user sum the total? Development expert Greg Low explains.Continue Reading
Stored procedure: Keep track of SQL Server Agent jobs
Enterprise Manager's standard tools aren't much help in examining SQL Agent jobs. To get details about jobs currently running, try this sp_ListJobInformation routine instead.Continue Reading
Stored procedure: Execute T-SQL code from a file
Need to execute T-SQL code in a file from within other T-SQL code? The sp_ExecuteSQLFromFile stored procedure addresses the shortcomings and adds new functionality.Continue Reading
-
Stored procedure: A simple way to perform crosstab operations
A crosstab operation usually involves complicated T-SQL coding or pulling data into an application, but sp_Crosstab makes it simple.Continue Reading
Undocumented SQL Server stored procedures
T-SQL commands should not be used to manipulate the file system for security reasons, but some undocumented SQL Server stored procedures can help you work with directories, files and drives.Continue Reading
Stored procedure: Search character columns for a given string
The sp_FindString routine allows you to search for occurrences of a string in the character columns (char, nchar, varchar, nvarchar) of a set of tables. The output includes the table name, column name and number of rows in which the string was found.Continue Reading
Undocumented stored procedure: Repair table indexes with sp_fixindex
One undocumented stored procedure in SQL Server 2000 can be used to repair a given system table index. Serdar Yegulalp explains how to use sp_fixindex to fix corrupted indexes and ensure a smooth-running SQL Server.Continue Reading
Stored procedures: Perform operations on SQL Server tables and objects
To perform a particular operation on a specified set of tables or objects, contributor Brian Walker offers two simple and flexible stored procedures: sp_FixTables and sp_FixObjects. These routines allow you to generate T-SQL code, immediately ...Continue Reading