From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create SQL "Databases" from LV?

Is there a way to create SQL Databases (not just tables) from inside LabVIEW???  This sould be fairly easy...
0 Kudos
Message 1 of 7
(3,460 Views)

All I know is what is in the SQL Server help file. There is the SQL command "CREATE DATABASE". An example is:

USE master
GO
CREATE DATABASE Sales
ON 
( NAME = Sales_dat,
   FILENAME = 'c:\program files\microsoft sql server\mssql\data\saledat.mdf',
   SIZE = 10,
   MAXSIZE = 50,
   FILEGROWTH = 5 )
LOG ON
( NAME = 'Sales_log',
   FILENAME = 'c:\program files\microsoft sql server\mssql\data\salelog.ldf',
   SIZE = 5MB,
   MAXSIZE = 25MB,
   FILEGROWTH = 5MB )
GO
 
You have to have the correct permissions in order to do this and the server itself has to exist. I'm assuming that you already have the Database Connectivity Toolkit, LabSQL (http://www.jeffreytravis.com/lost/labsql.html), or are using your own ADO routines.
Message 2 of 7
(3,442 Views)
I am using the LV "Database Connectivity Toolkit" that ships with the Prof. Dev. Suite.  I am going to download and look at LabSQL 1.1 from your website today.  I am assuming it offeres more speciallized SQL functionality?  Does it allow you to execute scripts like the one above from inside the LV block diagram?
0 Kudos
Message 3 of 7
(3,429 Views)
They both do. At the heart of the Database Connectivity Toolkit, it issues SQL commands. I don't have the toolkit but I'm pretty sure that there is a function in there to issue a SQL command directly. Most of the toolkit is functions that hide some of the complexity of SQL and allow you to build an application faster without knowing the SQL language. With LabSQL, the only interface is SQL through ADO.
0 Kudos
Message 4 of 7
(3,425 Views)

Here's an example of how to do any SQL query using the Database Connectivity Toolkit VIs:

 

0 Kudos
Message 5 of 7
(3,398 Views)
Your figure looks like its executing a select query or something similar, i.e. it returns a recordset. 
 
What would it look like executing a "create database" script?  Would it be the same, just without the "Fetch Data"?
 
Thanks.  Soon I need to stop asking questions and just go try this stuff 🙂
0 Kudos
Message 6 of 7
(3,379 Views)
Exactly, the code would be the same without the Fetch subVI. 
0 Kudos
Message 7 of 7
(3,355 Views)