Page 1 of 1

Problems creating an MSSQL database when using filespec

Posted: Mon Aug 18, 2008 5:12 pm
by Darren
Hi all,

I am evaluating Studio version and have a most of my install working. The big problem I have now is creating a database. I have incorporated the SQL sample project and its instance detection successfully. It validates that I am connecting to the database. When I use the exact same setup for the MS SQL Server plug-in and add a simple database creation script, it says it is successful but never creates the database. I am outputing in a Messagebox the return variable as well as all the other variables involved in the create script. They all have the right values.

Code: Select all

create database [$SQLDBNAME$] on primary
(name = N'$SQLDBNAME$_Data, filename = N'$SQLDATAFOLDER$\\$SQLDBNAME$_Data.MDF', size = 5MB, maxsize = unlimited, filegrowth = 10%),
filegroup [INDEX]
(name = N'$SQLDBNAME$_Index', filename = N'$SQLDATAFOLDER$\\$SQLDBNAME$_Index_Data.NDF', size = 5MB, maxsize = unlimited, filegrowth = 10%)
log on
(name = N'$SQLDBNAME$_Log', filename = N'$SQLDATAFOLDER$\\$SQLDBNAME$_Log.LDF, size = 5MB, maxsize = 1GB, filegrowth = 10%)
collate SQL_Latin1_General_CP1_CI_AS
go


If I just use "GO" and check the "Create database if absent" box then it creates the database. If I don't check the "Create database if absent" box and do nothing more than:

Code: Select all

create database [$SQLDBNAME$]


It works. Is there a bug? Is there a different way to accomplish this? We have an enterprise app that will require the flexibility to define a different location for SQL dB data files. IT groups frequently have non-default locations for these files.

I'm stuck. Any ideas? Any help?

Posted: Tue Aug 19, 2008 9:25 am
by Darren
Never mind :lol: I sorted it out. It came down to the script file not being saved properly as ANSI text. So for anyone else, if you are running SQL scripts from SQL Server plug-in, use Message Box to output the return variable. If you are getting "SUCCESS" from the result but the script isn't doing anything, then odds are good that your script file is not properly ANSI text. Open it up in notepad and do a "Save As" and make sure you choose "ANSI".

I've never had to be particular about saving a file as ANSI vs Unicode so it took me a while to figure out that my script was still saved as Unicode.

Posted: Tue Aug 19, 2008 11:04 am
by CandiceJones
Ah great to hear that! Yes all scripts must be ANSI.