sr_aneesh
January 23rd, 2005, 10:22 AM
I have a dbf file which has to be Exported to MS SQL 2000. ASP as the front-end as the records will be exported to SQL from the client.
what i currently do is : i take records from the dbf file one by one and insert into the SQl database.
for that i use stored procedure (code below). Here i also check if the record already exist in the SQL Database and if the field1 of table1 exist in the table2.
CREATE PROCEDURE sp_myprocedure
@field1 varchar(25),
@field2 varchar(25),
@field3 varchar(25),
@field4 varchar(25),
@field5 varchar(100),
@field6 varchar(25),
@field7 varchar(25)
AS
if exists(select field1 from table1 where field1=@field1 and field5=@field5) ' To Check if record already exit in the table1 '
return 555
else
if exists(select field1 from table2 where field1=@field1) 'Check if the field1 Exist in the table2 Table '
insert into table1 (field1,field2,field3,field4,field5,field6,field7) values(@field1,@field2,@field3,@field4,@field5,@field6,@field7)
GO
Even though the records are imported to the SQL from the dbf as per my requirement.
1. How do i count total number of records in the dbf files which already exist in the Table1 and list out the field1 which already exist.
2. How do i list out the field1 in the dbf which is not in the table2 as the records from the dbf files will only be inserted into the table1 if field1 exist in the table2.
Thanx in Advance.
what i currently do is : i take records from the dbf file one by one and insert into the SQl database.
for that i use stored procedure (code below). Here i also check if the record already exist in the SQL Database and if the field1 of table1 exist in the table2.
CREATE PROCEDURE sp_myprocedure
@field1 varchar(25),
@field2 varchar(25),
@field3 varchar(25),
@field4 varchar(25),
@field5 varchar(100),
@field6 varchar(25),
@field7 varchar(25)
AS
if exists(select field1 from table1 where field1=@field1 and field5=@field5) ' To Check if record already exit in the table1 '
return 555
else
if exists(select field1 from table2 where field1=@field1) 'Check if the field1 Exist in the table2 Table '
insert into table1 (field1,field2,field3,field4,field5,field6,field7) values(@field1,@field2,@field3,@field4,@field5,@field6,@field7)
GO
Even though the records are imported to the SQL from the dbf as per my requirement.
1. How do i count total number of records in the dbf files which already exist in the Table1 and list out the field1 which already exist.
2. How do i list out the field1 in the dbf which is not in the table2 as the records from the dbf files will only be inserted into the table1 if field1 exist in the table2.
Thanx in Advance.