Loading
Showing posts with label Transact-SQL. Show all posts
Showing posts with label Transact-SQL. Show all posts

Wednesday, October 21, 2009

Using Transact SQL to get length of TEXT field [T-SQL]

To calculate the lenght of a TEXT field the LEN function used to calculate the length of VARCHAR fields won't work.

You need to use the DATALENGTH T-SQL function:
SELECT DATALENGTH(myTextField) AS lengthOfMyTextField

Thursday, October 1, 2009

MS SQL Backup Database to Disk

To create a full database backup using Transact-SQL

Execute the BACKUP DATABASE statement to create the full database backup, specifying:
  1. The name of the database to back up.
  2. The backup device where the full database backup is written.
Example
BACKUP DATABASE AdventureWorks 
TO DISK = 'C:\Backups\AdventureWorks.BAK'