Hello everyone, I am bumping into a problem that is possible easy to solve, but since I am a noob in SQL server, I might be glitching somewhere.
I have a table that holds Image type called Attachments {id, external_id, file_data} which file_data is an Image type. This table file_data must be transfered to a table called UploadedData {id, description, file_data} and hold the generated ID in the attachments
in a field called upload_id.
So far so good:
IF NOT EXISTS(SELECT NULL from syscolumns where name = 'upload_id' AND id = object_id('attachments')) BEGIN ALTER TABLE attachments ADD upload_id INT NULL; ALTER TABLE attachments ADD CONSTRAINT fk_attachments_upload_id FOREIGN KEY (upload_id) REFERENCES uploaded_data(id); END GO
That is the code to add the upload_id in the attachments table, it worked. Now I have to run through all attachments and create a new record for each attachment in the uploaded_data and save this generated id in the attachment field upload_id. This is where i am glitching.
To be precise, I dont know how to do it, i tried creating a temporary table and inserting values there, but I dont know how to intermediate it between both. Any help, documentation, etc would be very appreciated.
With kindly regards
André