Thanks Naomi, I missed that part of the thread. I thought it was two databases on the same server. Your message should have gone to Peter though, not me...
>According to another message that database was not a SQL Server database, but local VFP database. Obviously, SQL Server can not see local VFP databases, so that insert must result in error.
>
>You may try using OpenQuery or linked server instead (if you installed SQL Server 32 bit).
>
>Check
http://fox.wikis.com/wc.dll?Wiki~VisualFoxProDataFromSQLServer>
>>>OK i get a connection now
>>>but this :
>>>
>>>
>>>
>>>gnConnHandle = SQLCONNECT("SQL")
>>>
>>>*SQLEXEC(gnConnHandle , [select * from contacts],"cc1") &&& works
>>>
>>>
>>>
>>>
>>>SQLEXEC(gnConnHandle , [INSERT INTO dbo.contacts (firstname,lastname) SELECT fname,lname FROM kba_data.contacts])
>>>
>>>SQLDISCONNECT(gnConnHandle )
>>>
>>>
>>>does not insert anything
>>>
>>>how would i do that correctly
>>>
>>>
>>>Peter
>>
>>what is the database name that holds contacts that you are inserting into? (Put correct stuff where square brackets are)
>>
>>SQLEXEC(gnConnHandle, "INSERT INTO [databasename].dbo.contacts (firstname, lastname) SELECT firstname, lastname from kba_data.dbo.contacts WHERE [add where condition here]"
>>
>>So if the database you are inserting into is kbb_data and you only wanted to insert records from kba_data that had the firstname of John:
>>
>>
>>SQLEXEC(gnConnHandle, "INSERT INTO kbb_data.dbo.contacts (firstname, lastname) SELECT firstname, lastname from kba_data.dbo.contacts WHERE firstname = 'John' ")
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"