Skip to main content
Inspiring
May 24, 2008
Answered

Multiple statements in one cfquery

  • May 24, 2008
  • 2 replies
  • 625 views
Providing there is only one or no SELECT statement, can I issue multiple statements to a database inside a single cfquery?

For example will this work correctly:

<cfquery datasource="myDB" username="myUserName" password="myPassword">
CREATE TABLE dbo.table1 ( ... );
CREATE INDEX Ix1 ON dbo.table1 (col1);
CREATE TABLE dbo.table2 ( ... );
etc...
</cfquery>

or must I SET NOCOUNT ON and put GO between each statement? (I am working with SQL Server 2005.)

Doug
This topic has been closed for replies.
Correct answer Newsgroup_User
doug777 wrote:
> or must I SET NOCOUNT ON and put GO between each statement? (I am working with
> SQL Server 2005.)

no, just wrap the mess of sql in a NOCOUNT ON/OFF block.

2 replies

doug777Author
Inspiring
May 24, 2008
Thanks very much. That makes the whole thing very straightforward.

Doug
Newsgroup_UserCorrect answer
Inspiring
May 24, 2008
doug777 wrote:
> or must I SET NOCOUNT ON and put GO between each statement? (I am working with
> SQL Server 2005.)

no, just wrap the mess of sql in a NOCOUNT ON/OFF block.