PrimalScript 2009 and SQL

PrimalScript 2009 has expanded its support for SQL in several major ways. Primary among these are the addition of SQL PrimalSense and the ability to edit and save stored procedures directly within a database. Let’s take a quick look at some of these new features.

Before you can work with SQL, you should first create a connection to a database. Open the Database Browser in PrimalScript and right click in the pane. Select “Create a new connection.” Immediately name the connection. Fill in the connection dialog boxes and press OK.  (If you are connecting to a SQL Server 2008 database you may want to select the “All” tab and set “Persistent Security Info” to TRUE in order for the connection to remember your password.) Your new connection is now ready to go!
So what can you do with this connection? One thing you can do is to drag that connection onto your script to add a connection string. It will place the full connection string right at the caret position. (The text below is split across two lines using the PowerShell line continuation character for clarity.”)

Picture 2 

You can also work directly with the tables in your connection. Go ahead and click on the + sign next to the connection name. Below you will see “Procedures”, “Views” and “Tables”.  Expand the “Procedures” node and take a look at the stored procedures in your database. Double click on one and the proc will be displayed in a document window as an “Alter Procedure” script.

At this point, you can easily alter your stored procedure. PrimalScript 2009 has added SQL PrimalSense support, so at any time you can press CTRL+space to pop up a list of tables, views and stored procedures that are available within your database.
But PrimalSense works even better! Bring up the database toolbar to set the current connection to the connection you want to use. In a new (or opened) SQL document start typing a SQL statement. After typing four characters, if PrimalSense recognizes the characters as belonging to an object in that connection, it will pop up a list of tables, procs, columns, etc. and select the first match.

Picture 6

Also, typing a table name and then a period will pop up a list of fields in that table.

Picture 5

In response to user feedback, we moved the Visual Query Builder out of PrimalScript 2009. But don’t fret, PrimalScript 2009 does offer a new Live SQL query window that enables ad-hoc query testing and live data manipulation. Simply type the query in the edit control and press Enter. Viola! Your results appear in a nicely formatted and editable table below.

Picture 4

The previously mentioned Visual Query Builder capability is now included in our stand-alone database front-end tool, PrimalSQL 2009.