I have developed a script that can be used to archive offline databases. This script first brings the databases online, then backs them up, detaches them, and then moves the MDF and LDF files.
Tag: Transact SQL
The script in this post can be used to obtain an example of each of the different styles that can be output using the CONVERT Transact-SQL statement when converting date/time to a string. I have output the styles including the century, but the script can easily be modified to output examples without.
If you need to analyse the number of email addresses by email domain, e.g. “@abc.com”, then the script within this post will return the number of records grouped by the domain name of each email address (i.e. to the right of the @ sign)
The script within this post, outputs a list of each DATETIME and SMALLDATETIME field within a database, along with the minimum and maximum values. Useful to identify tables that have a date created or updated column, and you want to find out if they are still being used.
Do you have any spurious characters in a field??
Well, the code within this post, can be used to obtain a list of the ASCII character codes for each individual character of a field
If you need to find out if a database is being used (or when it was last updated), a useful script contained within this post, will return the maximum date for each and every date/time field within all tables in the current database
Comparison between MIcrosoft SQL Server Transact-SQL and MySQL Syntax
Hi. The Transact-SQL script below returns the following information: ID – Just an identity column used within the script SchemaName – The name of the schema TableName – Obviously, the name of the table 🙂 ColumnName Type – The data type of the column Length – The maximum number of bytes used by the field […]
I wanted to produce a list of the MAX of date fields (DateTime, SmallDateTime, TimeStamp) for all tables within all databases held in an instance of SQL Server.
The script below was written for SQL Server 2000, but should be easily customisable for SQL Server 2005
The Transact-SQL Script below, is useful if you want to standardise the location of your databases. I have been managing a server whereby databases created by other people were created all over the place!! Therefore, this script was written to make life so much easier. 🙂 Be sure to read through the script before running it. […]
The query within this post returns the top 20 most used query plans that are cached by SQL Server for faster query execution.
I was on a training course at the end of September, and came across a way to execute a simple stored procedure as part of a select statement using an Inline Table Valued Function.
You (like me) have probably tried to run the following statement expecting to get results from a stored procedure: