How To Use INSERT INTO.... SELECT FROM Query To Export MS SQL Data In FoxPro 2.6 DBF

Nov 28, 2006

Hi all,

This is my very first post to this forum. How to use the INSERT INTO... SELECT FROM query to export MS SQL 2000 data into FoxPro 2.6 DBF file? I want to write a VB 6.0 program, and already connected to MS SQL 2000 Database by MS SQL ODBC connection. Now I want to Export this MS SQL data to FoxPro 2.6 DBF. I found ROWSET option, but don't know how to use it for FoxPro.
Please help me.

Thanks in Advance.

Regards,
Rajeev Vandakar

View 5 Replies


ADVERTISEMENT

Insert Data To Database Foxpro Using Open Query

Feb 24, 2014

Insert data to database foxpro using open query. I already create connection like below

@server = 'EXIMBIL_LINK',
@provider = 'MSDASQL',
@srvproduct = '',
@provstr = 'Driver={Microsoft Visual FoxPro Driver}; UID=;SourceDB=D: raining_testdata;SourceType=DBF ;Exclusive=No;BackgroundFetch=Yes'

when i try to show table van with command :

select * from openquery(EXIMBIL_LINK,'select * from van')

It show query running well but when i try to insert new row to table van with command :

INSERT into OpenQuery(EXIMBIL_LINK, 'SELECT c_user_id,c_user_name,full_name from van')
VALUES('1000007668','IDMTEST2','IDMTEST2')

throws error like this : Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done

View 1 Replies View Related

SQL Server 2012 :: Select Query To XLS Output - Export Data In Columns To Separate Tabs In Excel

Apr 21, 2015

Using below script to export the select statement result to .xls

declare @sql varchar(8000)
select @sql = 'bcp "select * from Databases..Table" queryout c:bcpTom.xls -c -t, -T -S' + @@servername
exec master..xp_cmdshell @sql

But result is not exporting in seperate tabs, all 4 column details are exporting in single cell.

how to export the data in columns to separate tabs in excel.

View 2 Replies View Related

Query Data From The Linked Foxpro Database

Aug 2, 2007

hello,guys,

my question is :
how do I query data from the linked foxpro database?

more:
I have linked a visual foxpro server to my sql server database by using the addserver clause.
Two server is in a local network.
My linked foxpro server named 'fox'.
its datasourse is not a dbc file, but a directory of dbf files ,and its full path is d:foxpro object.
In the directory ,there are three table,'show2003.dbf','sysu.dbf','szszj.dbf'.
And the .dbf files are not in any database.
They are just three files in the same directory.
There is no dbc file.
Now I can see the table list on the right page of the linked server.
But there is something wrong with my sql clause.

sample:

select * from fox..sysu


then the message is:
server: message 7313,level 16,status 1,row 1
the appointed constructure or directory to the provider is inefficacious 'MSDASQL'


I know I may use 'openquery',or 'openrowset'.
The problem is that variable is not valid in 'openquery' and 'openrowset'.
But I must use variable.
so ,please give me some advice.



Thank you very much

View 4 Replies View Related

Convert XML Data With Select Query And Insert Into Table?

Jun 19, 2014

I want to convert xml data with select query and insert into table.

Xml sample like this :

<ROOT>
<ROW>
<NAME>JHON</NAME>
<ADDRESS>
<ADDRESS1>
<CITY>LKO</CITY>
<STATE>UP</STATE>

[code]....

And data should be like this with select query :

NAME ADDRESS1CITY ADDRESS1STATE ADDRESS2CITY ADDRESS2STATE
JHON LKO UP DLI DELHI
YASH AAA HYR NULL NULL

I want simple query in form of above format.

View 8 Replies View Related

Foxpro Export

Jun 1, 2007

I'm trying to export the data from sql to foxpro dbf file. I can't seem to find the OLE in 2005 any where. Can some one give me the direction how to export and connect to foxpro dbf file from import/export wizard

thanks

View 1 Replies View Related

Sql To FoxPro Export

May 24, 2006

I have 2 packages, one to import data from Foxpro to Sql and another to send the data back from Sql to FoxPro.

The time it takes to execute the package that moves 2 million rows of data from FoxPro to Sql takes about 18 to 25 mins. Not bad. However, moving approximately the same number of rows from Sql back to FoxPro takes about 8 hrs. Not acceptable. I have tried several things with no luck.

Any advice would be appreciated.

V

View 3 Replies View Related

Export SQL Svr '05 Table To FoxPro DBF

Dec 14, 2007

Does anyone know how I can, using SQL and/or T-SQL syntax (although I could do a CLR in C# too..), export a SQL table from SQL Server 2005 to a new Visual FoxPro 9 DBF (table)? The DBF would need to be created on the fly too because this will have to basically be able to export any SQL table...

Thanks ahead of time for any and all assistance...

View 1 Replies View Related

Insert Into SQL From Foxpro

Jul 20, 2005

I have a recordset in my VB6 app that was created using ODBC and I would like to insert the data into a SQL db table. I already have the target Db & table setup. What is the fastest way to accomplish the data transfer? Can I do a Select into using the ODBC recordset as my source?Thanks

View 1 Replies View Related

Export Data To SQL Insert Statements?

Nov 13, 2006

Is it possible to export data from tables to SQL insert statements?  Got SQL 2005 developer, visual studio 2005, and Visio enterprise architect, if that makes any difference.   I already found this tool but it costs money.

View 1 Replies View Related

Export Data Into A Script As Insert Into's

Sep 22, 2004

Hello,

I am using a Web based front end to a SQL Server db installed at my host that only lets me import data into tables either manually (in a 'datasheet' view) or with a SQL query.

Does anybody know if I can export data from my local db as a script such as

insert into TestTable(Id, Name) values ("1", "Test1")
insert into TestTable(Id, Name) values ("2", "Test2")
.
.
.

... so that I can run this script on the Web front end and insert data into the db at my host?

Many thanks in advance.

View 2 Replies View Related

Export Data From SELECT Statement

Sep 4, 2007

Hello,

I have a SELECT statement which returns a result, depending on the selection the users make (application written in Visual Basic 2005). I want to export the result of the SELECT statement to a Excel file (.csv, or .txt). How should I proceed?

View 1 Replies View Related

Export Data And Insert Into Text File

Apr 29, 2015

I have the data of ACTTAB, APTTAB and etc, how to i export this data from SQL and insert into a text file??? this is the first time i need to do. as for the 2nd thing is that after export the data from SQL into text file, i need to import this data into mongoDB. So basically how to export this following data (ACTTAB, APTTAB and etc) into text file?

View 7 Replies View Related

Export Table Data Into A Series Of Insert Statements (or Alternative)

Jan 29, 2008

Hi all,

I have a table which I would like to export to a series of insert statements (in a file maybe). Is this possible somehow?

Alternatively, I could use an existing xml document which contains table metadata (table name, column names,types etc) to transfer data from these particular columns to another database replica.

Thanks,
Yannis

View 10 Replies View Related

How Do I Export Data From MS SQL Server Tables To Text File With 'insert' Statements

Jan 3, 2005

I am trying to take an entire MS SQL database and put it in an sql file. I have succesfully copied the tables into an sql file by highlighting the tables in enterprise manager and choosing 'generate sql script'.

That gives me the structure, but now I would like the data (in insert statements). I have looked in enterprise manager's export wizard and sql analyzer to no avail. There seem to be a lot of options for exporting data except this one! Please point me in the right direction.

At the end of the day, I would like to be able to put everything in a text file. Then, should I have problems, I can just copy my text into query analyzer and have a brand new database.

Thank you in advance.

View 4 Replies View Related

Export Data From Excel2003 To Sql Query

Mar 26, 2008

hi
i have a problem
and i hope u can help me

i want to write sql query into vba
how i do that

(i need to take the data from one cell and put it
in my sql query )

thank u all

View 1 Replies View Related

Insert Data To A Table Where Select Data From Another SERVER

Oct 8, 2007

I had a function like below :Public Sub Getdata2(ByVal query, ByVal db, ByVal name)
Dim selectSQL As StringDim con As SqlConnection
Dim cmd As SqlCommand
Dim reader As SqlDataReader
Trycon = New SqlConnection("User ID=xxx;password=xxx;persist security info=True;Initial Catalog=database1;Data Source=xxx.xxx.xxx.xxx.xxx,xxxxx;")
Dim username As String
username = Request.QueryString("username")
selectSQL = "SET DATEFORMAT DMY;Insert into table1(hse_num, st_name, proj_name, unit_num, postal, n_postal, flr_area, flr_sf, flr_rate, flr_ra_sf, land_area, land_sf, land_rate, lnd_ra_sf, prop_code, cont_date, title, sisv_ref, r_date, rec_num, source, username, DGP, Remarks, Sub_Code, caveat, consider, age) select hse_num, st_name, proj_name, unit_num, postal, n_postal, flr_area, flr_sf, flr_rate, flr_ra_sf, land_area, land_sf, land_rate, lnd_ra_sf, prop_code, cont_date, title, sisv_ref, r_date, rec_num, source, '" & username & "', DGP, Remarks, Sub_Code, caveat, consider, age from [yyy.yyy.yyy.yyy,yyyy].database2.dbo.table2 where " & querycmd = New SqlCommand(selectSQL, con)
con.Open()
reader = cmd.ExecuteReader()
lbl.Text = selectSQLCatch ex As Exception
lbl.Text = ex.Message
Finally
If (Not con Is Nothing) Then
con.Close()
con.Dispose()
End If
End Try
End Sub
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
May i know that how do i retrieve data from  [yyy.yyy.yyy.yyy,yyyy].database2.dbo.table2 due to diffrent server, diffrent UID and Password
 

View 1 Replies View Related

Insert Query With A Select Subquery

Apr 1, 2008

Hi.I have an insert query which inserts record that are returned from a select subquery:
INSERT tbl1 (col1,col2,col3) SELECT (col1,col2,col3) FROM tbl2 WHERE...
col1 and col2 in tbl1 combined ,are a unique index.
So, as I understand it sql server first returns all the records from tbl2 and then starts to insert them one by one into tbl1.
The problem is, that if one of the records returned from tbl2 violates the unique keys constraint in tbl1, sql server will not insert all of the records (even those which maintain the key constraint).How can I solve this ?

View 4 Replies View Related

Insert Query Problem And Also Select

Jun 12, 2006

I have a Bit field in my database ,but when i try to insert the bit in database it inserted succesfully but while accessing it returns -1,what would be the problem?
i used integer while inserting same as get the value from database?
 

View 1 Replies View Related

Insert Query With A Select Subquery

Apr 1, 2008

Hi.
I have an insert query which inserts record that are rturned from a select subquery:

INSERT tbl1 (col1,col2,col3) SELECT (col1,col2,col3) FROM tbl2 WHERE...

col1 and col2 in tbl1 combined ,are a unique index.

So, as I understand it sql server first returns all the records from tbl2 and then starts to insert them one by one into tbl1.

The problem is, that if one of the records returned from tbl2 violates the unique keys constraint in tbl1, sql server will not insert all of the records (even those which maintain the key constraint).
How can I solve this ?

View 6 Replies View Related

Insert Based On A Select Query

Sep 20, 2005

Hi,I have a SQL query:select products.name, products.notes, products.purchase_date,products.serial_no, products.total_value, products.product_code,products.quantity, products.product_group, products.lhs1_name,lhs1.department, lhs1.address1, lhs1.city, lhs1.countryfrom products, lhs1where products.lhs1_id = lhs1.idI want to insert the results of this query into a table called 'temp' in thedatabase. I used to copy and paste this into excel then import it but itdoesn't always work.Is there a way to do it all in a SQL script. Please be aware that myknowledge of SQL is fairly basic so please explain things clearly.Thanks,Darren

View 4 Replies View Related

How To Use Select Statement In Insert Query

Jul 20, 2005

hi my self avii want to copy data from one table to other table,by giving certaincondition and i want o use insert statement .in this i want to pass somevalue directly and some value from select statement , if i try i ll geterror i.e all column of destination table (i.e in which i want to insertdata) should match with all columns in values column some thing likethis.plz give me some helpful suggetion on this

View 1 Replies View Related

Query Problem : Export Data : URGENT PLZ

Jun 1, 2001

Hello!

Can someone help me writting a query to export data in following fashion :

Old Structrure: I've a single table (Countries) with columns CountryID, CountryName, CityName

New Structure: I want to break this single table into two tables now (Countries) and (Cities). New Structure should be like following:

Countries Table:
- CountryID
- CountryName

Cities Table:
- CityID (Auto Generated)
- CountryID (FK from Countries)
- CityName

I would really appreciate if someone can help me to write the query which can export the Data from Countries Table to the new Cities Table.

Thanks.

View 1 Replies View Related

SQL 2012 :: Export Data To Excel Using Query?

Mar 4, 2015

I need to export the data directly using a query from sql server. This is just a temporary extract. Copy pasting the result in excel is giving mis-alignment.

View 1 Replies View Related

How To Export SQL Data To Excel SpreadSheet Using SQL Query?

Aug 2, 2006

Hi

Im using this query to select ,calculate and format data like Refer here for more understanding:-


Select DateAdd(Hour, DateDiff(Hour, 0, RowDateTime), 0) As RowDateTime,
Avg(Meter1) As Meter1,
Avg(Meter2) As Meter2,
Avg(Meter3) As Meter3
From TableName
Group By DateAdd(Hour, DateDiff(Hour, 0, RowDateTime), 0)


I want the output of the query to be written in the excel Sheet.

Your help will be highly appreciated.

View 13 Replies View Related

FoxPro Triggers Call FoxPro Stored Proc Calls SQL Server Stored Procedure

Mar 10, 2005

I didn't want to maintain similar/identical tables in a legacy FoxPro system and another system with SQL Server back end. Both systems are active, but some tables are shared.

Initially I was going to use a Linked Server to the FoxPro to pull the FP data when needed. This works. But, I've come up with what I believe is a better solution. Keep in mind that these tables are largely static - occassional changes, edits.

I will do a 1 time DTS from FP into SQL Server tables.

I then create INSERT and UPDATE triggers within FoxPro.

These triggers fire a stored procedure in FoxPro that establishes a connection to the SQL Server and fire the appropriate stored procedure on SQL Server to CREATE and/or UPDATE the corresponding table there.

In the end - the tables are local to both apps.

If the UPDATES or TRIGGERS fail I write to an error log - and in that rare case - I can manually fix. I could set it up to email me from within FoxPro as well if needed.

Here's the FoxPro and SQL Server code for reference for the Record Insert:

FOXPRO employee.dbf InsertTrigger:
employee_insert_trigger(VAL(Employee.ep_pk),Employ ee.fname,Employee.lname,Employee.email,Employee.us er_login,Employee.phone)

FOXPRO corresponding Stored Procedure:
FUNCTION EMPLOYEE_INSERT_TRIGGER
PARAMETERS wepk,wefname,welname,weemail,WEUSERID,WEPHONE

nhandle=SQLCONNECT('SS_PDITHP3','userid','password ')

IF nhandle<0
m.errclose=.f.
IF !USED("errorlog")
USE tisdata!errorlog IN SELECT(1)
m.errclose=.t.
ENDIF

SELECT errorlog
INSERT INTO errorlog (date, time, program,source,user) ;
values (DATE(), TIME(), 'EMPLOYEE_INSERT_TRIGGER','nhandle<0 PARAMS: '+STR(wepk)+wefname+welname+weemail+WEUSERID+WEPHO NE,GETENV("username"))

IF m.errclose
USE IN errorlog
ENDIF
RETURN

ENDIF
nquery="exec ewo_sp_insertNewEmployee @WEPK ="+STR(wepk)+",@WEFNAME ='"+wefname+"',@WELNAME ='"+welname+"',@WEEMAIL ='"+weemail+"',@WEUSERID ='"+weuserid+"',@WEPHONE='"+wephone+"',@RETCODE =0"
nsucc=SQLEXEC(nhandle,nquery)

SQLDISCONNECT(nhandle)

IF nSucc<0
m.errclose=.f.
IF !USED("errorlog")
USE tisdata!errorlog IN SELECT(1)
m.errclose=.t.
ENDIF

SELECT errorlog
INSERT INTO errorlog (date, time, program,source,user) ;
values (DATE(), TIME(), 'EMPLOYEE_INSERT_TRIGGER','nSucc<0 PARAMS: '+STR(wepk)+wefname+welname+weemail+WEUSERID+WEPHO NE,GETENV("username"))

IF m.errclose
USE IN errorlog
ENDIF
ENDIF

RETURN

SQL SERVER Stored Procedure called from FOXPRO Stored Procedure
CREATE procedure ewo_sp_insertNewEmployee (
@WEPK int,
@WEFNAME char(20),
@WELNAME char(20),
@WEEMAIL char(50),
@WEUSERID char(15),
@WEPHONE char(25),
@RETCODE int OUTPUT
)

AS

insert into WO_EMP (
WE_PK,
WE_FNAME,
WE_LNAME,
WE_EMAIL,
WE_USERID,
WE_PHONE
)

VALUES (
@WEPK,
@WEFNAME,
@WELNAME,
@WEEMAIL,
@WEUSERID,
@WEPHONE
)


IF @@ERROR <> 0
BEGIN
SET @RETCODE=@@ERROR
END
ELSE
BEGIN
-- SUCCESS!!
SET @RETCODE=0
END

return @RETCODE
GO

View 2 Replies View Related

Insert Statement Using Results Of Select Query

Feb 11, 2015

I need to insert data into a table based on the results returned by a select statement. Basically, the select statement below gives me a list of all the work orders created in the last hour.

select worknumber from worksorderhdr where date_created > DATEADD(HOUR, -1, GETDATE())

This might return anywhere between 5 and 50 records each time. What I then need to do is use each of the work numbers returned to create a record in the spec_checklist_remind table. The other details in the insert statement will be the same for each insert, it's just the worknumber from the select statement that needs to be added to the insert where the ?? are below:

INSERT INTO spec_checklist_remind (form, record_type, linked_to_worknumber, spec_checklist_id) values (5, 0, '??',52)"

View 2 Replies View Related

Insert Query With Nested Select And Parameter

Jul 20, 2005

hey there, i'm trying to move one record from one table to the next,so i'm doing this by doing an insert into table, then delete from theprevious table. Only thin g is on the insert i want to include aparameter. Can't work how to do this. Do you think i need to doanother update query and insert the parameter that way, after theinsert is done?ALTER PROCEDURE dbo.ReturnLoan(@strBarcode varchar(100),@strLibrary varchar(100),@dateReturned datetime)ASINSERT INTO Loan_History(Barcode,UserID,Date_Borrowed,Library)Select Barcode, UserID, Date_Borrowed, Library FROM Loans WHEREBarcode = @strBarcodeAND Library = @strLibrary;DELETE FROM LoansWHERE Barcode = @strBarcodeAND Library = @strLibrary ;RETURN

View 1 Replies View Related

Single SQL Query To Two Foxpro (ODBC) Connections

Nov 4, 2004

Dear All,

I like to know if anyone of you out there can help me solve this issue. I need to generate an SQL Query to access two different FOXPro (databases) connections.

Example,
Connection 1 - has a DSN setup of CMSBM and it sits in the path of D:/CMS/CMSBM/= and the table is bmboml15
Connection 2 - has a DSN setup of CMSMA and it sits in the path of
D:/CMS/CMSMA/= and the table is maprodl15

I am coding in ASP.NET using C#. I have tried the command like:

SELECT codeno, link, type FROM bmboml15 IN CMSBM INNER JOIN maprodl15 IN CMSMA ON bmboml15.codeno = maprodl15.codeno.

Obviously the above query is not a working one and a very poor construction.

Please help!

Thanks
Clo

View 1 Replies View Related

SQL Tools :: Export Data To PDF And Send It By Mail Using A Query

Jul 8, 2015

i like to know if there is a way to export data to pdf and send it by mail using a query same way used to export to csv or text file "sp_send_dbmail".

View 6 Replies View Related

Insert Record In Table - Select Output Of Query

Oct 14, 2013

I had a query and i need to insert record in table and also want to select output of query.

Actually I need to insert and show data in same query.

;with cte as (
select id , status
from tbl_main
where id = 15555
)
insert into testinsert (id , status)
select * from cte

View 3 Replies View Related

Pass A Variable To A Linked Server (FoxPro) Query

Nov 22, 2004

I'm having problem with an OpenQuery statement in stored procedure, which should be run on FoxPro linked server. I'm getting either an error messages or not the result I expected. I know that the problem is with WHERE part, without this part it works.


Here is the code:
-------------------------------------
DECLARE @LastDate datetime
SELECT @LastDate = MAX(DateChaged)
FROM tblPersonel
WHERE ACTIVE IN( 'A', 'T')

1. I tried:
SELECT * FROM OPENQUERY(FoxProLink, 'SELECT ACTIVE, EmpNumber FROM tblPersonel WHERE DateChanged >=''+@LastDate+''')

This line gives me an error msg:

Could not execute query against OLE DB provider 'MSDASQL'.
[OLE/DB provider returned message: [Microsoft][ODBC Visual FoxPro Driver]Operator/operand type mismatch.]


2. I tried to use CTOD() - FOXPRO function to convert character to date.

SELECT * FROM OPENQUERY(FoxProLink, 'SELECT ACTIVE, EmpNumber FROM tblPersonel WHERE DateChanged >=CTOD(''+@LastDate+'')')

-this doesn't give any error, but doesn't limit the result set as it should.

Thanks all.

View 2 Replies View Related

How To Select && Insert Data In The Same Table

May 24, 2007

Hi
   I have a table called Version and its attributes are Version_ID, Project_ID , Hospital_ ID , Date_Created and comments. I want to select the data by Version_ID,Project_ID and  Hospital_ID and the selected data is inserted in the same table(Version) as new row .
Table: Version (Version_ID(Primary_key), Project_ID(Foreign_Key),Hospital_ID(Foreign_Key),Date_Created,Comments). 
Iam using Visual Web Developer Express and SQL Server 2005. Iam doing on asp.net 2.0.
Could anyone please send me the code asp.net 2.0 for the above problem.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved