Click here to Skip to main content
11,495,716 members (54,341 online)
   

Database

 
AnswerRe: Windows Run Command Pin
Eddy Vluggen1-Oct-12 6:09
memberEddy Vluggen1-Oct-12 6:09 
QuestionRe: Windows Run Command Pin
jojoba20111-Oct-12 23:09
memberjojoba20111-Oct-12 23:09 
AnswerRe: Windows Run Command Pin
Eddy Vluggen2-Oct-12 1:58
memberEddy Vluggen2-Oct-12 1:58 
QuestionRe: Windows Run Command Pin
jojoba20112-Oct-12 7:58
memberjojoba20112-Oct-12 7:58 
AnswerRe: Windows Run Command Pin
Eddy Vluggen2-Oct-12 9:08
memberEddy Vluggen2-Oct-12 9:08 
QuestionMySQL Question Pin
SQL Ed28-Sep-12 5:21
memberSQL Ed28-Sep-12 5:21 
AnswerRe: MySQL Question Pin
Eddy Vluggen29-Sep-12 3:38
memberEddy Vluggen29-Sep-12 3:38 
QuestionRemoving the updated row Pin
sindhuan28-Sep-12 2:48
membersindhuan28-Sep-12 2:48 
Hi All
I have merged data into a new table say table1 from table2(need to do this every time data comes into table2..Both the tables have following columns Id,Period(which includes date and time)Constraint(flag is only for table1)
Once the data is merged into table1 the data in table2 gets deleted automatically.when a new data comes into table2 it checks whether the period(only date not the time) in table1 and table2 matches..If it gets matched then we update the constraint flag of table1 to "1". then we add this new data from table2 to table1..Then I should remove the old data...what I wanted to do now is remove the data whose contraint flag is 1 from table1

I have given the code what I have done..Can some one help how to proceed

MERGE INTO table1 AS t1
USING table2 AS t2
ON t1.Id=t2.UsagePointId

WHEN MATCHED THEN
UPDATE SET
AND t1.period=t2.period
t1.constraint=0

WHEN NOT MATCHED THEN
INSERT (Id, period,constraint)
VALUES (t2.Id,t2.period, 0);


WITH x AS
(
SELECT t1.constraint
FROM table1 AS t1
JOIN table2 AS t2
ON t1.Id=t2.Id
AND t1.period =t2.period
)
UPDATE x
SET constraint=1;
WHERE t1.period AS DATE =upi.t2.period AS DATE
QuestionMySQL sql statement question Pin
jrahma27-Sep-12 10:28
memberjrahma27-Sep-12 10:28 
AnswerRe: MySQL sql statement question Pin
jschell27-Sep-12 11:12
memberjschell27-Sep-12 11:12 
GeneralRe: MySQL sql statement question Pin
jrahma27-Sep-12 12:08
memberjrahma27-Sep-12 12:08 
GeneralRe: MySQL sql statement question Pin
Eddy Vluggen29-Sep-12 3:42
memberEddy Vluggen29-Sep-12 3:42 
QuestionIs there a try/finally construct in sqlcmd with -b option, guaranteed to execute the finally block? Pin
muhalet27-Sep-12 1:56
membermuhalet27-Sep-12 1:56 
AnswerRe: Is there a try/finally construct in sqlcmd with -b option, guaranteed to execute the finally block? Pin
Eddy Vluggen27-Sep-12 2:42
memberEddy Vluggen27-Sep-12 2:42 
GeneralRe: Is there a try/finally construct in sqlcmd with -b option, guaranteed to execute the finally block? Pin
J4amieC27-Sep-12 3:51
memberJ4amieC27-Sep-12 3:51 
QuestionRe: Is there a try/finally construct in sqlcmd with -b option, guaranteed to execute the finally block? Pin
Eddy Vluggen27-Sep-12 5:27
memberEddy Vluggen27-Sep-12 5:27 
AnswerRe: Is there a try/finally construct in sqlcmd with -b option, guaranteed to execute the finally block? Pin
J4amieC27-Sep-12 22:29
memberJ4amieC27-Sep-12 22:29 
Questionsql script [modified] Pin
sindhuan26-Sep-12 21:08
membersindhuan26-Sep-12 21:08 
AnswerRe: sql script Pin
ihoecken26-Sep-12 22:10
memberihoecken26-Sep-12 22:10 
GeneralRe: sql script Pin
sindhuan26-Sep-12 22:21
membersindhuan26-Sep-12 22:21 
AnswerRe: sql script Pin
ihoecken26-Sep-12 22:44
memberihoecken26-Sep-12 22:44 
AnswerRe: sql script Pin
J4amieC26-Sep-12 22:46
memberJ4amieC26-Sep-12 22:46 
GeneralRe: sql script Pin
sindhuan27-Sep-12 0:30
membersindhuan27-Sep-12 0:30 
AnswerRe: sql script Pin
ihoecken27-Sep-12 1:07
memberihoecken27-Sep-12 1:07 
GeneralRe: sql script Pin
Eddy Vluggen27-Sep-12 1:22
memberEddy Vluggen27-Sep-12 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 29 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid