I'm trying to insert values into the same database from itself.
Essentially, I want to add another row to the table for each row with
reg_cat_id = 3. But in this row, I want the original registration_id
to show up in the new row.
Here is my syntax below - this generates an error:
INSERT INTO Registration_Category
(REG_CAT_ID, REGISTRATION_ID, STAFF_ID,
REGISTRATION_DATE, APPROVAL_STATUS, APPROVEDDATE)
VALUES (90, t1.REGISTRATION_ID, 'test', '05/05/2007', 'Y',
'05/05/2007')
SELECT REGISTRATION_ID, STAFF_ID,
REGISTRATION_DATE, APPROVAL_STATUS, APPROVEDDATE
FROM Registration_Category t1
WHERE (REG_CAT_ID = 3)
ORDER BY REGISTRATION_ID
Any suggestions?On 30 Mar 2006 14:40:12 -0800, Dee wrote:
(snip)
>Here is my syntax below - this generates an error:
>INSERT INTO Registration_Category
> (REG_CAT_ID, REGISTRATION_ID, STAFF_ID,
>REGISTRATION_DATE, APPROVAL_STATUS, APPROVEDDATE)
>VALUES (90, t1.REGISTRATION_ID, 'test', '05/05/2007', 'Y',
>'05/05/2007')
> SELECT REGISTRATION_ID, STAFF_ID,
>REGISTRATION_DATE, APPROVAL_STATUS, APPROVEDDATE
> FROM Registration_Category t1
> WHERE (REG_CAT_ID = 3)
> ORDER BY REGISTRATION_ID
>Any suggestions?
INSERT INTO Registration_Category
(REG_CAT_ID, REGISTRATION_ID, STAFF_ID,
REGISTRATION_DATE, APPROVAL_STATUS, APPROVEDDATE)
SELECT 90, t1.REGISTRATION_ID, 'test',
'20070505', 'Y', '20070505')
FROM Registration_Category AS t1
WHERE REG_CAT_ID = 3
Hugo Kornelis, SQL Server MVP
Showing posts with label itself. Show all posts
Showing posts with label itself. Show all posts
Thursday, March 29, 2012
Thursday, February 16, 2012
Can a job trigger itself upon receipt of an email?
Hi all,
I have a SQL Server Job that I would like to run when I receive an email saying "Data is now ready to be imported to SQL Server" ?
Is there a way to accomplish this.
- Vivekgot a mapi compliant mail server laying around. you might be able to do this with sqlmail.
OR
i have never written too much VBA for outlook (mostly access and excel) but you maybe able to write a rule that drops this email in a certain folder. Then, and I am not sure if there is an event for new mail but there probably is, you can probably make a db call in that event. you would have to leave your mail client open and your computer on.|||Check out xp_readmail in SQL BOL. Basically, you would need to put this inside a SQL Job that executes periodically and then use xp_readmail to "answer" the inbox and trigger your job.
Having said all that, I will say that SQL mail only ever caused me grief and heartache. Go Database Mail (SQL 2004)!
Regards,
hmscott
I have a SQL Server Job that I would like to run when I receive an email saying "Data is now ready to be imported to SQL Server" ?
Is there a way to accomplish this.
- Vivekgot a mapi compliant mail server laying around. you might be able to do this with sqlmail.
OR
i have never written too much VBA for outlook (mostly access and excel) but you maybe able to write a rule that drops this email in a certain folder. Then, and I am not sure if there is an event for new mail but there probably is, you can probably make a db call in that event. you would have to leave your mail client open and your computer on.|||Check out xp_readmail in SQL BOL. Basically, you would need to put this inside a SQL Job that executes periodically and then use xp_readmail to "answer" the inbox and trigger your job.
Having said all that, I will say that SQL mail only ever caused me grief and heartache. Go Database Mail (SQL 2004)!
Regards,
hmscott
Subscribe to:
Posts (Atom)