SQL Server's VARBINARY datatype allows us store BLOB data like Images, word documents etc., Lets see how that works with an example:
1.Create Table:
CREATE TABLE dbo.Consultants
(
ID INT IDENTITY(1,1),
ConsultantName VARCHAR(50),
ResumeDoc VARBINARY(MAX)
)
3. Check the Output:
SELECT ID, ConsultantName, ResumeDoc FROM dbo.Consultants
1.Create Table:
CREATE TABLE dbo.Consultants
(
ID INT IDENTITY(1,1),
ConsultantName VARCHAR(50),
ResumeDoc VARBINARY(MAX)
)
Once we have the table created, lets insert a resume located in some folder (D:\Steve_Resume.docx) into the table.
2. Query:
INSERT INTO dbo.Consultants (ConsultantName, ResumeDoc)
SELECT 'Steve', * FROM OPENROWSET (BULK N'D:\Steve_Resume.docx', SINGLE_BLOB) Doc
3. Check the Output:
SELECT ID, ConsultantName, ResumeDoc FROM dbo.Consultants
Hope this helps! Happy TSQLing !
Important: I will discuss how to extract the Resume from the SQL Server Table back to a windows folder location in the next post.
Important: I will discuss how to extract the Resume from the SQL Server Table back to a windows folder location in the next post.
No comments:
Post a Comment