25 pts.
 Using MAX data types in SQL Server
I'm new to using large data types (varchar(max))and after reading an article (Using MAX data types in SQL Server) I have a few questions. I am trying to understand how you insert such a long string (up to 2 billion char) in the database table? I am assuming this would include storing Word Documents, etc. in the data base. If this is true, what is the method used to store the document in the data base? What is the max length of the Command String that is submitted to SQL Server?

Software/Hardware used:
ASKED: December 20, 2007  6:03 PM
UPDATED: February 22, 2008  4:55 AM

Answer Wiki:
You can insert data using a standard insert statement if you'd like. Most people will write a stored procedure which accepts the blob data as an input parameter and then the stored procedure will do the actual insert. You can then call the procedure from your calling application in a parameterized mode so that you don't have to write the actuall execute command. Your stored procedure would look something like this. <pre>CREATE PROCEDURE usp_InsertWorkDoc @FileName nvarchar(255), @FileData varbinary(max) AS INSERT INTO FileTable (FileName, FileData) values (@FileName, @FileData) GO</pre> You will want to put some data checking to make sure that the file doesn't already exist. You'll also notice that I used the varbinary(max) data type. Word Docs are binary are as such need to be stored in a binary data type. _______ Thanks, Hank1039
Last Wiki Answer Submitted:  December 21, 2007  3:32 pm  by  Denny Cherry   64,505 pts.
All Answer Wiki Contributors:  Denny Cherry   64,505 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Did this answer your question?

 64,505 pts.