SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Copy image from one table to another
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

xsbucks
Starting Member

1 Posts

Posted - 02/18/2013 :  14:05:32  Show Profile  Reply with Quote
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 - 02/18/2013 :  17:07:30  Show Profile  Reply with Quote
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 - 02/18/2013 :  17:54:29  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 02/18/2013 :  23:47:29  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000