You would create a table which contains the attachment(s). This child table would have information to identify the attachment, the attachment itself (or better a reference to the attachment which itself is stored elsewhere) and information which relates the attachment back to your main table, i.e. the child table contains a foreign key relationship back to your main table. I'm making some gross assumptions about the nature of your data, since you supplied no information about that:
Code:
CREATE TABLE YourMainTable(
MainTableKey varchar(10) NOT NULL PRIMARY KEY,
...);
CREATE TABLE Attachments(
AttachmentKey varchar(10) NOT NULL PRIMARY KEY,
MainTableKey varchar(10) NOT BULL REFERENCES YourMainTable(MainTableKey),
Attachment varchar(xx) NOT NULL,
...);
What is the nature of the "attachments" you refer to? If they are large, or contain binary data (an image, for example) then many people (me included) think it is better to store the attachment in the filesystem someplace, and only store the path to the attachment in the database. It is possible to store large images or large text (up to 2GB each) in the database (see the 'text' and 'image' datatype in BOL), but I personally don't recommend that. Others have disagreed and say they have had success storing the "attachment" in the database directly without incident. YMMV.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com