17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1: Storing and Managing Unstructured Data-- Create a table and insert a rowCREATE TABLE BlobTable(TextValue TEXT ,VarcharMaxValue VARCHAR(MAX))INSERT INTO BlobTable( TextValue ,VarcharMaxValue)SELECT '<strong>The</strong> text data type is invalid for local variables.' ,'However VARCHAR(MAX) is valid'-- Reading the first 20 characters from the TEXT columnDECLARE @val VARBINARY(16)SELECT @val = TEXTPTR(TextValue)FROM BlobTableREADTEXT BlobTable.TextValue @val 0 20-- Reading the first 20 characters from the VARCHAR(MAX) columnSELECT LEFT(VarcharMaxValue, 20)FROM BlobTableListing 1-4:Working with the new LOB data types is much easier.All <strong>of</strong> the new LOB data types introduced in <strong>SQL</strong> <strong>Server</strong> 2005 support storage <strong>of</strong> up to2 GB <strong>of</strong> data in a single column.VARBINARY(10) -- Can store up to 10 BytesVARBINARY(8000) -- Can store up to 8000 BytesVARBINARY(8001) -- Error!!!VARBINARY(MAX) -- Can store up to 2 GB <strong>of</strong> dataListing 1-5:MAX identifier raises the storage capacity from 8,000 bytes to 2 GB.31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!