Creating a MSSQL database

Is it possible to create a new MS SQL database from a query or a coldfusion script?

We try to create respective databases and their data sources on the fly.  We have conquered the creation of a new source of data successfully and coldfusion has a variety of support for creating tables, change their etc.,.

but you can create a new database itself with coldfusion on the fly?

Thanks in advance,

Brian

For example, it would be possible to run this script where #FORM.datasource # is a form of a web form variable...

CREATE the DATABASE [#FORM.datasource #] ON PRIMARY
(NAME = no #FORM.datasource #', FILENAME = is C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\#FORM.datasource#.mdf', SIZE = 2048 KB, FILEGROWTH = 1 024 KB)
OPEN A SESSION
(NAME = no #FORM.datasource #_log ', FILENAME = is C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\#FORM.datasource#_log.ldf', SIZE = 1024KO, FILEGROWTH = 10%)
GO
EXEC dbo.sp_dbcmptlevel @dbname = no #FORM.datasource #', @new_cmptlevel = 90
GO
IF (1 = FULLTEXTSERVICEPROPERTY ('IsFullTextInstalled'))
Start
EXEC [#FORM.datasource #]. [dbo]. [sp_fulltext_database] @action = "disable."
end
GO
ALTER DATABASE [#FORM.datasource #] ANSI_NULL_DEFAULT OFF SET
GO
ALTER DATABASE [#FORM.datasource #] SET ANSI_NULLS OFF
GO
ALTER DATABASE [#FORM.datasource #] SET ANSI_PADDING OFF
GO
ALTER DATABASE [#FORM.datasource #] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [#FORM.datasource #] SET ARITHABORT OFF
GO
ALTER DATABASE [#FORM.datasource #] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [#FORM.datasource #] AUTO_CREATE_STATISTICS is SET TO
GO
ALTER DATABASE [#FORM.datasource #] AUTO_SHRINK OFF SET
GO
ALTER DATABASE [#FORM.datasource #] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [#FORM.datasource #] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [#FORM.datasource #] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [#FORM.datasource #] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [#FORM.datasource #] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [#FORM.datasource #] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [#FORM.datasource #] RECURSIVE_TRIGGERS OFF SET
GO
ALTER DATABASE [#FORM.datasource #] AUTO_UPDATE_STATISTICS_ASYNC OFF SET
GO
ALTER DATABASE [#FORM.datasource #] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [#FORM.datasource #] SET SIMPLE PARAMETERIZATION
GO
ALTER DATABASE SET READ_WRITE [#FORM.datasource #]
GO
ALTER DATABASE [#FORM.datasource #] SET RECOVERY FULL
GO
ALTER DATABASE [#FORM.datasource #] SET MULTI_USER
GO
ALTER DATABASE [#FORM.datasource #] SET PAGE_VERIFY CHECKSUM
GO
USE [#FORM.datasource #]
GO
If NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default = 1 AND name = no PRIMARY') ALTER DATABASE [#FORM.datasource #] by DEFAULT MODIFY FILEGROUP [PRIMARY]
GO

Technically no, because ColdFusion does nothing.  There is no bundle up the SQL string and pass it to the database driver.

But yes, you can provide any valid SQL inside a block of and it will be passeed to the database and the database is going to do everything that the SQL statement attempts to ask him to perform.

Of course, this assumes that security has not been implemented to prevent such use in the database.  I.E. it is generally considered a very bad idea to have the database account ColdFusion connects with to create, modify and delete permissions.  The ColdFusion Administrator also offers a security feature to try to deny these chains of command from the SQL statements being processed.

But if you're willing to live with that risk, you can have your CFML code are all sorts of powerful things with your database, just be aware that if, you can get your CFML to do, hackers may be able to do the same.

Tags: ColdFusion

Similar Questions

  • Create the remote database using dblink view

    Hello

    I have a small question for you.

    Is it possible to create the remote database using dblink view? Following syntax error

    create discover ViewName@DbLinkDame (ColumnName) as
    (select 1 double)

    "ORA-00905: lack of keyword.

    Is this possible at all?
    And particularly - is this possible when the remote database is MSSQL and I use heterogeneous services?

    I really appreciate your help
    Best regards
    Wojtek

    Published by: wojpik on October 21, 2009 03:59

    This is a workaround for a remote Oracle database (use the queue of work), however:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:597877500346143250

    but I have no idea if something similar is possible for MSSQL...

  • create the new database programmatically

    I am creating a new MS Access database you want to connect a few results for in a labview program using the toolkit of connectivity datab ase.  The examples show how link and create a new table in an existing database file, but I want to create a new database and then insert a new table inside for my results.  Any ideas?

    You have installed Access where you can create a blank MDB file?  If so, you can create an and store it as a template in your program folder.  Copy and paste when you run your routine and use table VI to create in the Toolbox to create tables to write.  It is possible to create tables in an INSERT, but you can't control the properties of the fields.  The OP in this thread is doing this thing. (http://forums.ni.com/t5/LabVIEW/Database-connectivity-toolkit/m-p/3046359#M868188)

  • Can I create a web database search that does not use Javascript?

    Can I create a web database search that does not use Javascript?

    While it would be possible to do it through custom coding, this type of web database search would not supported by Eloqua.

  • How can I create a new database without table using database configuration

    How can I create a new database without table using database configuration

    You can search for your "DBA 2 days" version oracle documentation for your version.  You should also read the manual of the concepts.  Create your own schema is pretty basic, all you have to do is to create a user.  Don't use dba or system for your own objects.

  • I can't access my main database after you create the second database.

    I installed oracle server 11.2.0.1.0 on windows server 2008, the installer to create a database for me called "orcl", then I could connect with the database

    use System Manager, I created another user in this db called x... etc, then I created an another database called 'pure', using dbca (database configuration

    assistance), I put the password of user on the system (in pure db) is 'oracle', after the creation process, I was able to connect with this database

    using System/oracle but

    I tried to connect to the first db using System/Manager, that I could not, I get "name of user and password invalid connection refused."

    I tried conn system/manager@orcl, but I could not also...

    Help me please to connect with the first database.

    Thank you.

    C:\>set ORACLE_SID = orcl

    System/Manager C:\>sqlplus

  • ORA-20002: you can't create links from database

    HI Experts,

    Creating database link, I get the error below. Anyone of you could please have some light on this error. I googled for this error and did not get any update.

    Oracle version: 11.2.0.3

    The user with whom I created this link of database DBA privilege.

    SQL > create database link temp_LINK connect to account identified by * using "(DESCRIPTION = (ADRESSE = (COMMUNUITY=tcp.world) (PROTOCOL = TCP)(Host=myself.us.lev.com) (Port = 1525)) (CONNECT_DATA = (SID = LNDB1DB)))'; "
    create database link temp_LINK connect to account identified by * using "(DESCRIPTION = (ADRESSE = (COMMUNUITY=tcp.world) (PROTOCOL = TCP)(Host=myself.us.lev.com) (Port = 1525)) (CONNECT_DATA = (SID = LNDB1DB)))'; "
    *
    ERROR at line 1:
    ORA-00604: error occurred at the SQL level 1 recursive
    ORA-20002: you can't create links from database
    ORA-06512: at line 4


    Thank you..

    Well Yes, this request confirmed suspicion of SB.

    The datadictionary is your friend

  • Can we create a local database with SQl developer 3.1

    Hi I am trying to create a local database that I can run in my machine. Should what username and password I use. Do I need it, where to find it.

    Thank you

    If your instance of XE and SQL Developer are on the same machine, try right-clicking on the node 'Connections', then 'create local connections. This will create connections, which you can then use to administer the complete database, including the schemas provided apex. If you do it yourself, just use 'localhost' or 127.0.0.1 as the host of the db.

  • EAL: Create error Essbase database

    Hi all

    I am confronted because of EAL Bridge to create the essbase application. using the version 11.1.2.2. Please let me know if anyone has idea about this error.

    Message board:
    Validation is performed successfully
    Mapping data is reloaded with success
    Error: Could not create the Essbase database

    Thank you
    Kiran

    Published by: kirannch on October 9, 2012 18:04

    In the registry on the essbase and EAL servers go to

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\TCPIP\Parameters

    Add the following DWORD key with decimal values

    MaxUserPort: 65534
    TcpTimeWaitDelay: 30

    Restart the servers

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • How to create the new database in oracle 11g

    Hello
    I m new in oracle 11g, I downloaded oracle 11g and with the help of the guide of the developer-2 days, I learned all the SQL queries, but I worked with human resources database.
    Now, I want to create my own database with the required tables. Can anyone help me how I can make my own database in oracle 11g.

    Thank you
    Manna

    870692 wrote:
    Hello
    I m new in oracle 11g, I downloaded oracle 11g and with the help of the guide of the developer-2 days, I learned all the SQL queries, but I worked with human resources database.
    Now, I want to create my own database with the required tables. Can anyone help me how I can make my own database in oracle 11g.

    Thank you
    Manna

    Be sure to distinguish between the terms and the database schema. Other products, make them bad. It would be a HR diagram (or a user, which is the same in Oracle). If you do not need to use the database Wizard, unless you are working with a new host with no database.

    A simple way would be to get the DDL to create the HR schema and modify it for your own. It can be extracted from your database in several ways, or you can copy the hr_cre.sql to your own script and change. The two ways are educational, and you can google for instructions.

  • Create the new database of complete hot RMAN, atrchivelog and backup control files

    Hi all

    I'm trying to create the new database U1234 of P1234 of full hot RMAN, atrchivelog and control P1234 file backup.

    Here are my steps

    (1) to restore the control file

    #! / bin/sh
    ORACLE_SID = P1234
    export ORACLE_SID
    RMAN nocatalog target / < < EOF | Tee restorecontrol.out
    startup nomount pfile=/u01/oradba/admin/U1234/scripts/restore/restore071009U1234/initP1234.ora;
    the value of DBID 6767676;
    run
    {
    allocate channel d1 type disk;
    controfile catering to ' / u02/oradba/U1234/control/P1234_control01.ctl';
    Restore controlfile to ' / orarman/restore/P1234/cf_P1234_c-00';
    change the editing of the database;
    }
    EXPRESSIONS OF FOLKLORE

    (2) database stop then restart the database with the new contraol file using pfile.

    (3) restore data files

    #! / bin/sh
    ORACLE_SID = P1234
    export ORACLE_SID
    RMAN nocatalog target / < < EOF | Tee restore_dbfiles.out
    Run {}
    the value of newname for datafile 1 to ' / u05/oradba/U1234/dbfile/U1234_system01.dbf';
    the value of newname for datafile 2 to ' / u05/oradba/U1234/dbfile/U1234_undotbs01.dbf';
    the value of newname for datafile 3 to ' / u05/oradba/U1234/dbfile/U1234_sysaux01.dbf';
    the value of newname for datafile 4 to ' / u06/oradba/U1234/dbfile/U1234_users_d01.dbf';
    the value of newname for datafile 5 to ' / u06/oradba/U1234/dbfile/U1234_tools_d01.dbf';
    the value of newname for datafile 6 to ' / u08/oradba/U1234/dbfile/U1234_audt_x01.dbf';
    the value of newname for datafile 7 to ' / u07/oradba/U1234/dbfile/U1234_audt_d01.dbf';
    the value of newname for datafile 8 to ' / u07/oradba/U1234/dbfile/U1234_audt_d02.dbf';
    the value of newname for datafile 9 to ' / u08/oradba/U1234/dbfile/U1234_lh_x01.dbf';
    restore the database;
    switch datafile;
    }
    EXPRESSIONS OF FOLKLORE


    ORA-27063: number of bytes read or written is incorrect
    SVR4 error: 28: no space is available on the device

    Now, I missed the space during the restoration of data files and want to restore remaining who is 3 and 4 of datafile datafile.

    Can you please let me know how I can restore it.

    I need to change the names of database after the successful restoration.

    DBVERSION 10.2.0.1
    operating system: solaris 10

    Thanks in advance.

    Hello..

    Do you have free space? If Yes, then you can try: -.

    RUN {}
    SET NEWNAME for DATAFILE 3 to ' / u05/oradba/U1234/dbfile/U1234_sysaux01.dbf';
    RESTORE THE 3 DATA FILE;
    DATAFILE 3 SWITCH;
    }

    [http://www.oracle-base.com/articles/9i/DBNEWID.php]

    Anand

  • undesirable type is created in the database

    Hi all

    I found a type created with the name SYSTPYbjDiyxqMdngRAAUT3s/bA == in my database without any body type and dependencies.

    No idea what makes of this type with the name of junk SYSTPYbjDiyxqMdngRAAUT3s/bA == create in my database

    I m using Oracle 10 g

    Thanks n rgds
    Saaz

    It is not the recyclebin.

    As mentioned in Alex, this is a type of system generated.

    There are a few scenarios where they created automatically behind the scenes, according to what you do with plsql types (for example, the Pipeline functions) or during certain SQL operations on SQL types where you don't expect the system to need to.

  • Creating a new database with the file exporrt

    Hello


    I am to create a new database with an export file.


    I have the export file (exp) and the environment put in place (Oracle10g on UNIX)


    Can you gimme a few guidelines and this lines that I could probably face and again to correct.



    Kind regards.

    Hello..

    Aman has already given a link, to cross.

    Well, as you already have a new environment 10g put in place, create tablespaces and users, (accurate to the source database) with the script from the source database, and then import (imp) the export dump using fromuser touser parameter.

    Anand

  • Can TestStand create a new database

    I have what I thought, it was a simple question, but I can't find the solution.

    When you use the data logging choose us what file it is written (I use Access). I was wondering if there is a way to have TestStand automatically create and save a new file based on the serial number entered during testing.

    Thus, instead of having 1 Access file with all serial numbers inside (i.e. TestSolutions.mdb).

    We would have several Access files all found: numbers of input during the test series. (e.g. 123.mdb, 124.mdb, 125.mdb and so on if entered during testing serial numbers was 123,124,125).

    Also, this should add an already created Access file if the serial number is repeated.

    Thanks for all the help.

    According to my experience, the database must be created with the appropriate tables and relationships before the test can start.

    But in your case, you could do the following:

    1.) create a default "template.mdb' which is empty and contains all the necessary tables.

    2.) scan your serial number and COPY your "template.mdb" at .  I could easily do in LabVIEW.

    You can make the change of name in the DatabaseOptions reminder.  It is important to set the ConnectionString property.

    For example, I use the following connection string...

    Parameters.DatabaseOptions.ConnectionString="\"Provider=Microsoft.Jet.OLEDB.4.0; Data source = C:\\Program Files\\; «Persist Security Info = False\»»

    I never thought I'd create separate databases for each serial number, is there a reason why you should do this?

    PH

  • create the new database in MAX

    Is - this possibible to create a database on a shared network drive? I get the error message: "cannot create the database: access is denied."

    I really can't understand this as...

    (1) I "should" have all permissions to the drive letter, I want to put the database.

    (2) the creation of a database on a "D" drive connected on the computer very well SATA works.

    MAX somehow only 'know', that it is a shared network location and prevent its use?

    Any help would be appreciated, I couldn't find through the help files for MAX if there is such a thing as a 'valid' for a database location.

    RichA

    Thanks for your suggestion, it lets me know I have recommended such configured mine. The suggestion is in alignment with how I have mine currently configured. (standby server takes over when the main server will down. used standby server only until I can get the Server primary back. and while the standby server is down, they have a tendency just to this time.)

    Thanks again,

    RichA

Maybe you are looking for