Learn more about Toad for SQL Server
at Dell Software

Find solutions and downloads at the
Toad for SQL Server Support Portal

Toad for SQL Server 6.6

You are here: Edit SQL > Create and Edit SQL > Toad Script Example

Toad Script Example

The following script demonstrates how to use Toad Script functions. This script creates the number of tables you specify. The script prompts you for the number of tables to create and the number of rows to create.

For more information about Toad Script functions and how to use them, see About Toad Script.

--: PROMPT tableCount = 'Enter the number of test tables to create'

--: SET i = 0

--: WHILE i < tableCount

--: SET i = i + 1  

CREATE TABLE testTable{{Unquote(:i)}} ( id INT PRIMARY KEY );

--: ENDWHILE

--: NOTIFY 'Done creating tables.'

--: ASK addData = 'Fill tables with test data?'

--: IF addData

--: PROMPT rowCount = 'Enter number of rows to create'  

--: SET i = 0  

--: WHILE i < tableCount  

--: SET i = i + 1    

--: SET j = 1    

--: WHILE j <= rowCount    

INSERT INTOtestTable{{Unquote(:i)}} VALUES (:j);

--: SET j = j + 1      

--: ENDWHILE    

--: PRINT 'Completed filling table ' || i    

--: ENDWHILE  

--:ENDIF

 

of