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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is semicolon required for Batch of sql statements?

Status
Not open for further replies.

pctest

Programmer
Apr 12, 2004
89
0
0
US
According to SQL BOL, semicolon is required to separate statements. But I can issue the following using VFP8SP1 and ODBC:

csql = "select * from table1 " + ;
"select * from table2"
sqlexec(1, csql)

It works as long as there is a space to separate the statements.

I wonder whether this will only work for certan version of ODBC.

Thank you.

 
Are you saying that you actually get two separate cursors returned with this SQLEXEC()? Or do you simply get one or the other and SQL server doesn't complain?

Rick
 
I got 2 separate cursors and SQL Server doesn't complain.
 
Pctest,

The answer depends on which back end you are using. With most servers, you will need the semi colons. However, SQL Server is very intelligent in figuring out where one statement begins and the next one ends.

So the following syntax is OK with SQL Server:

lcCmd = "SELECT * FROM Clients SELECT * FROM Orders EXEC MyProc"
SLQEXEC(lnConn,lcCmd,"MyCursor")

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Mike,

I'm using MS SQL Server 7 and MS SQL Server 2000.

Have you seen any case that no semicolon will cause problem for these backends?
 
Pctest,

Have you seen any case that no semicolon will cause problem for these backends?

No. I've used SQL Server 7.0 and 2000 for several years, and can't ever recall this causing a problem.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top