Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I made a SQL database backup through VFP

Status
Not open for further replies.

Xaplytz

Programmer
Jun 26, 2000
79
US
I made a SQL database backup through VFP

I run my program through a stored procedure in SQL

[ CREATE PROCEDURE test_backup
AS
BACKUP DATABASE sample TO DISK="c:\test\bck.dat" ]

In VFP I run this command: [ sqlexe(xc,’tes_backup’) ]

This does work. I would rather create the stored procedure in SQL directly from VFP. However, SQLEXE() doesn’t allow me create a procedure.

If somebody knows how create a stored procedure in SQL through VFP
I will appreciate any help.

Thank you.

[sig][/sig]
 
m.lcVar = [CREATE PROEDURE ...]
sqlexec(xc,m.lcVar) - && create it

sqlexe(xc,’tes_backup’) - && run it
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Thank you but
I tried that before and didn’t work
I have a table with memo fileds that contain all the scripts I will need

The scripts to create a table work well
The script to create index work well
Almost everything work ok by SQLEXE()

But the scripts to create procedures, backups, restores or database don’t work by SQLEXE()
But I test them in the query-analyzer and work ok

[sig][/sig]
 
Javier, I cranked up my SQL Server 7 and did the following:

[tt]nHandle = sqlconnect(&quot;MySecretConnection&quot;)
? sqlexec(nHandle, &quot;create procedure test as select * from person&quot;)[/tt]

My results: the stored procedure &quot;test&quot; was created successfully; I verified it by going into EM and seeing that it was there and valid.

My guess: you may be trying to put carriage returns or some other breaks in your CREATE PROCEDURE statement; don't.

[sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Robert,
AFAIK carriage returns do not affect SQL commands running at all. The syntax of character strings you pass to SQL server from VFP is the same as syntax you use in the SQL Server tools - you may write multi-line command(s). For example, you may run 3 different SQL commands in a single SQLEXEC() call. This is true for all commands, but I read somewhere about problems with SELECT/INSERT with VFP-style parameters when they contain CRs or appended/leaded by additional SQL commands.
In addition, SQL Server procedures may be quite complex and may contain more than 1 line of commands. To create it, carriage returns are required. And HERE may be a problem.
I don;t know exactly syntax of such definitions, but I know that this should work from VFP too.
Ceck also following, I'm not sure it will help, but I did not tried:
Carriage return (CR - code 13) often go together with additional character (Line Feed - LF, code 10). Ie:
line1CRLF
line2CRLF...
Javierp, when you type something in VFP memo field, new lines inserted using CRLF codes, not just CR. Maybe here is a problem - SQL Server does not like LFs...
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
yes I tried make a other procedure and works but when I try this

CREATE PROCEDURE test_backup
AS
BACKUP DATABASE sample TO DISK=&quot;c:\test\bck.dat&quot;

Doesn’t

Only does by Enterprise manager or Query analyzer
[sig][/sig]
 
I fixed it
All the problem was “ “ in SQL if you don’t use double quotes just single
The SQL put that text in red as bad syntax that is way I wrote with double.

--old—with problems in VFP
CREATE PROCEDURE test_backup
AS
BACKUP DATABASE sample TO DISK=&quot;c:\test\bck.dat&quot;

To fixed I just change =”c:\test\bck.dat” by ‘c:\test\bck.dat’

-New—works ok in VFP
CREATE PROCEDURE test_backup
AS
BACKUP DATABASE sample TO DISK=’c:\test\bck.dat’

Even when I see it by SQL the text have red color is working well.

Thank every body for your helps

Javier
[sig][/sig]
 
Me too. Looks like VFP influence, VFP allows both '' and &quot;&quot;... [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top