I want to put the same data from table A into table B as query , so that I can call the query through code.
I want to always delete TAble B then add update the same columns in table A to Table B, can someone help me with query.
Table A:
column A, column B, Column C
1 3 6
Table B:
column A, column B, Column C
? ? ?
Loading
David SmithPosted Sep 22, 2010, 6:10 PM
So I decided to just pull everything from memory which works very well for me instead of trying to execute the query from access. For some reasons thats the only query that dont work for me. The rest of the queries im calling from access works fine. Thanks for your help krishna
David SmithPosted Sep 22, 2010, 10:21 AM
CREATE PROCEDURE proc_TrunandInser
AS
BEGIN
truncate table Example
INSERT INTO Example(OpTimeStamp,UutMSN,maxoftestid,maxoftestnames, Status) select OpTimeStamp,UutMSN,maxoftestid,maxoftestnames,Status
FROM CIF_TestErrors_Crosstab
END
David SmithPosted Sep 22, 2010, 10:21 AM
CREATE PROCEDURE proc_TrunandInser
AS
BEGIN
truncate table Example
INSERT INTO Example(OpTimeStamp,UutMSN,maxoftestid,maxoftestnames, Status) select OpTimeStamp,UutMSN,maxoftestid,maxoftestnames,Status
FROM CIF_TestErrors_Crosstab
END
David SmithPosted Sep 22, 2010, 2:12 AM
Posted Sep 22, 2010, 1:59 AM
Truncate and insert are two different sql statements.If u want both to happen simultaneously then u have to include it inside a stored procedure and execute the procedure whenever u want the actions to be done....
Here is the procedure
CREATE PROCEDURE proc_TrunandInser
AS
BEGIN
truncate table Example
INSERT INTO Example(OpTimeStamp,UutMSN,maxoftestid,maxoftestnames, Status) select OpTimeStamp,UutMSN,maxoftestid,maxoftestnames,Status FROM CIF_TestErrors_Crosstab
END
First Execute the procedure in the database which u are using....
Now u can execute this procedure using the sql statement exec proc_TrunandInser
Hope i made myself clear
With Regards
P.Krishna Prasad
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If Someway my answer helped u... Don't forget to mark it as correct answer....
David SmithPosted Sep 22, 2010, 1:48 AM
I do have a question when I add the truncate table Example, on top of the insert I get a syntax error, how do i include the truncate table as part of the query
truncate table Example
INSERT INTO Example(OpTimeStamp,UutMSN,maxoftestid,maxoftestnames, Status) select OpTimeStamp,UutMSN,maxoftestid,maxoftestnames, Status FROM CIF_TestErrors_Crosstab
Posted Sep 21, 2010, 11:54 PM
AS per your req..
To always delete the content in table retaining it's structure use truncate table tbl2
To insert value from table A to table B use insert into tbl2(colA,colB,colC) select colA,colB,colC from tbl1
If u want both to happen write it as a stored procedure....
Hope i made myself clear
With Regards
P.Krishna Prasad
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If Someway my answer helped u... Don't forget to mark it as correct answer....