Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Copy image from one table to another

Author  Topic 

xsbucks
Starting Member

1 Post

Posted - 2013-02-18 : 14:05:32
I am very new to SQL, wondering if there is a way;

Scenario:
User uploads photo into one table via field on frontend.
I need photo to go to another Table for another component i am using.
Photo is now master photo on both components .

erikhaselhofer
Starting Member

30 Posts

Posted - 2013-02-18 : 17:07:30
This will meet your specified request.

CREATE TABLE junk (id int);
CREATE TABLE junk1 (id int);
IF OBJECT_ID ('someTrigger', 'TR') IS NOT NULL
DROP TRIGGER someTrigger;
GO
CREATE TRIGGER someTrigger
ON junk
AFTER INSERT
AS
INSERT INTO junk1
SELECT id FROM inserted; -- Gets value from insert.
GO
INSERT INTO junk VALUES (123);
SELECT * FROM junk; -- Confirms insert.
SELECT * FROM junk1; -- Confirms trigger fired.
Go to Top of Page

srimami
Posting Yak Master

160 Posts

Posted - 2013-02-18 : 17:54:29
Are the tables under the same database? If not, use Import/export to copy the table contents from one table to another from source DB to Target DB. Even if they are from the same database, you can use the same specifying the source and target table names
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-18 : 23:47:29
are photos stored in db itself? or is it just photo path you put in db?

We usually store only paths in db and actual images on file system

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -