Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Execute sp_test.sql from VFP9
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01101143
Message ID:
01101146
Views:
12
The GO is not T-SQL command but a QA batch separator. If you have multiple batches separated by GO in the file, you have to parse file and send one batch at a time. Something like
...
lcStr = FileToStr(tcSqlScriptFile) 
DO WHILE Not Empty(lcStr)
	lnGoPos = AT("GO" + CHR(13)+CHR(10), UPPER(lcStr))
	lcSqlScript = LEFT(lcStr, lnGOPos-1)
	lcStr = SUBSTR(lcStr, lnGoPos + 4)
	llOk =  ( SqlExec(lnConn, lcSqlScript) > 0 )
	
	IF Not llOk
           * Error 
           ...
	ENDIF

ENDDO
Keep in mind that it's incomplete sample code. You'll have to adjust it for your needs.

>want to run a sp_test.sql
>
>if exists (select * from sysobjects where id = object_id('sp_test') and sysstat & 0xf = 4)
>	drop procedure sp_test
>go
>Create Procedure sp_test
>as
>select GetDate() as DateTime
>go
>--Exec sp_test
>
>
>using this VFP code
>
>
>SqlCmd = FILETOSTR('C:\Projects\IMS\Sql\Procedures\sp_test.sql')
>RetVal = SQLEXEC( ConNumber, SqlCmd, "" )
>IF RetVal < 0
>	=AERROR(aErrorArray)  && Data from most recent error
>	FOR n = 1 TO 7
>		? n,aErrorArray(n)
>	ENDFOR	
>endif
>
>
>
>getting this error
>
>Line 4: Incorrect syntax near 'go'.
>
>
>I can run this same sp_test.sql using QA and it does ok.
>what is the difference.
>can you help?
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform