Using MAX data types in SQL Server

25 pts.
Tags:
Data management and storage
MAX
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?

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Denny Cherry
    Did this answer your question?
    66,005 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following