Dynamic Database Creation

Apr 6, 2007

Hi All,

I have a web site where the user can select from a list of databases (they're actually all the same structure, but have data unique to each client). Each database is a SQL 2005 database held in the App_Data folder. This all works a treat. Each database is simply named after the client it is holding data for, and the connection string for each is stored in a database that is accessed

However, what I need is a form where  a database name can be entered, and I can then create a new database with the same structure as the others - including tables, indexes and stored-procedures. I know I can use the copy database wizard in the Management Studio, but that isn't an option to the users of this system (it's to be used on an intranet, and the page I'm trying to create will only be used by project managers - but these people won't have a clue when it comes to configuring databases themselves). I have scripted a database, but have no idea on how I can actually use this script from within Visual Studio and more importantly, don't know how to configue it to have the database name as a parameter.

I've also seen some examples that suggest using SQL-DMO, but haven't been able to work out how to use it and according to Microsoft it shouldn't be used for new developments (http://msdn2.microsoft.com/en-us/library/ms132924.aspx).

Anyway, I really hope someone is able to offer some assistance on this one as I've spent a whole day trawling forums and various web-sites trying to find a solution to this.

Thanks & regards,

Paul

View 2 Replies


ADVERTISEMENT

Integration Services :: Dynamic Creation On DataBase

Jul 31, 2015

I have a reqirement where in i need to create a Database dynamically in SSIS, Database name is given in table.

View 5 Replies View Related

Analysis :: SSIS Dynamic Database Creation

Jul 31, 2015

I have a requirement where in i need to create a Database dynamically in SSIS, Database name is given in table.

View 3 Replies View Related

Dynamic Table Creation

Apr 19, 2007

Hi,I'm trying to create some tables dynamically based on the content of another table in the same database. I found a post that does what I want to do, but I can't get my code (that is similar to the post) to work.Given below is my code: 1 DECLARE @deptCode varchar(50), @numberOfDept int, @tableName varchar(MAX), @columnName varchar(MAX)
2 DECLARE @lengthDeptCode int, @lengthTableName int, @lengthColumnName int
3
4 SELECT @numberOfDept = COUNT(DISTINCT DeptCode)
5 FROM tbl_Department;
6
7 WHILE (@numberOfDept >=0)
8 BEGIN
9 SELECT @deptCode = DeptCode, @lengthDeptCode = LEN(DeptCode)
10 FROM tbl_Department;
11
12 SET @tableName = 'tbl_ProjectNumber'+@deptCode
13 SET @lengthTableName = LEN(@tableName)
14 SET @columnName = 'ProjectNumber'+@deptCode
15 SET @lengthColumnName = LEN(@columnName)
16
17 CREATE TABLE CAST(@tableName as char(@lengthTableName))
18 (
19 CAST(@columnName as char(@lengthColumnName)) int IDENTITY(1,1) NOT NULL
20 )
21
22 SET @numberOfDept = @numberOfDept - 1
23 END
  This is actually my first time using SQL programatically so I'm guessing there are alot of problems with it. I just don't know what exactly. The error I get is:Msg 102, Level 15, State 1, Line 18Incorrect syntax near '@tableName'. Thanks. 

View 1 Replies View Related

Dynamic Table Name Creation...

Jun 19, 2007

Hi there,I am trying to generate tables names on the fly depending on another table. So i am creating a local variable containing the table names as required. I am storing the tables in a local variable called@TABLENAME VARCHAR(16)and when i say SELECT * FROM @TABLENAMEit is giving me an error and I think I cannot  declare @TABLENAME as a table variable because I do not want to create a temp table of sorts.I hope I am clear.thanks,Murthy here 

View 6 Replies View Related

Dynamic Table Creation

Mar 19, 2004

Suppose I have a table named table1 which has a field question_Id.There are many values for this field say 100,101,102.
Now I want to make a table with the field name 100,101,102 but the problem is that it is not fixed how many values are there for question_id.Here in this example I mentioned three(100,101,102) but it may be anything.How can I make a table with the field names this way?
Subhasish

View 3 Replies View Related

Dynamic Table Creation/Modification

Oct 1, 2006

I'm wondering if there is a control available for creating/modifying db tables through a web interface. I want for users to be able to add/remove, rename, and change the datatype of certain fields in a database table. I've been searching all day online if such a control exists in asp.net but haven't found anything. 

View 1 Replies View Related

Dynamic Flat File Creation!

May 14, 2008

I'm trying to read the folder which has flat files and transform it and put it another folder with the SAME original name.
I created a For Eachloop containter and assign it to variable infile. In the data flow I added some transform and flat file destination. currently its reading 3 files and output is only one file.
I would like to create dynamic flat file connection so that it'll create separate files (same name) in different folder.
Thanks,

View 5 Replies View Related

Dynamic Flat File Creation

Mar 19, 2008



Hi All,


I'm new to SSIS. I have a small problem. In our system we are trying to create flat files based on data from returned from different SQL stored procedures. The configuration settings for creating the flat files are stored in a SQL table.

For example, the config table will look like below :

Feed Id Feed Name Feed File Name Feed Stored Procedure Name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 Biz C:Biz.txt dvx_GetBiz
2 PG C:PG.csv dvx_GetPG
3 NexT C:NexT.txt dvx_GetNexT
4 Amez C:Amez.csv dvx_GetAmez

The problem is dvx_GetBiz, dvx_GetPG,... all have different number and types of columns. So, I'm not able to create a dynamic Flat File destination depending on the columns returned from the corresponding stored procedure.

Is there a way to accomplish this ?

Pl. help.

Awaiting someones reply ASAP.

Thanks & Regards,
Vidya.




View 4 Replies View Related

Creation Of Dynamic Cubes Using XMLA?

Mar 12, 2008

I hope some of you can point me in the right direction. I am new to all this and
working on a project using Cubes.

The cubes need to be generated in a dynamic fashion as the contents
(that means field) in the fact tables change change every quarter and are
based off of a external application.

The base strucutre stays the same though. So we thought we would export the
XMLA representation of the cube and then munge (word for alter) the data in the
XMLA file and send it someplace to create the new cube on a SQL 2005 server.
This seemed easy enough but I have found no real information on how to
run some piece of code that would create the cube based on this XMLA code.

On another note is there a parsing object for the XMLA so i dont have to right one from
scratch?

Thanks,

Bob


View 1 Replies View Related

Dynamic Excel Creation In SSIS

Feb 26, 2008

Hi All, i've been reading this article http://rafael-salas.blogspot.com/2006/12/import-header-line-tables-_116683388696570741.html

in regards to creating an excel spreadsheet dynamically in SQL Server 2005 SSIS. However, i'm constantly getting an where the tab is created but not being populated. Can somebody post up a clearer example?

The problem I'm trying to solve is to automate the export of a query onto a new dynamic spreadsheet each time I run this SSIS package.

Any help would be greatly appreciated.

Thank you.

View 3 Replies View Related

Dynamic Login && User Creation

Mar 27, 2006

Hello. I'm trying to create a new login and username inside a trigger using variables.

This code works:

create login testUserName with password = 'testPassword'

The problem comes when I try to use variables for the username and password like this.

create login @username with password = @password

Does anybody know how to get around this problem?

BTW, the error message it gives is this, but I really doubt that semicolons have anything to do with it. If I literally type my data in the create login call it works fine, but when I use variables it doesn't.

Msg 102, Level 15, State 1, Line 14

Incorrect syntax near '@username'.

Msg 319, Level 15, State 1, Line 14

Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

View 8 Replies View Related

Dynamic Creation Of Temp Tables Using Managed Code

Jan 23, 2008



Hi,
I have a requirement to create #Temp table in database and insert values to it.

I use following code:

DbCommand dbCreateTable;

dbCreateTable = provider.CreateCommand();

dbCreateTable.Connection = conn;

dbCreateTable.CommandText ="Create table #MyTemp (Id varchar(10))";

dbCreateTable.ExecuteNonQuery();

string[] insertValues = {"Insert into #Mytemp values ('TestString1')",

"Insert into #Mytemp values ('TestString2')"};

DbCommand dbInsertData = provider.CreateCommand();

dbInsertData.Connection = conn;

foreach (String insertStr in insertValues)

{

dbInsertData.CommandText = insertStr;

dbInsertData.ExecuteNonQuery();

}

Code creates the Temp table but when it comes to insert statement, it throws error saying "Temp table not found".
Reason can be Create and Insert statement gets executed as 2 different sessions.
How to get the above requirement work fine?
Thank you.
HV

View 4 Replies View Related

Database Creation

Jan 11, 2008

Hi,
I am not sure is this a proper place for my question.
All we know that creating a database can be done as the following.
1) Create a project named DBExample
2) Click Add->New Item.
3) Select SQL Databse and type a name.(Ex:  Database1.mdf) A database is added to the project
4) Then add table and input values.
5) Set the primary key....
My question is I parsed a text file to form a 2d string array x. How can I convert x into the database?
 
Thanks

View 4 Replies View Related

Database Creation

Aug 16, 2005

Hello...
I want to develop a web site having two features
1. Online Shopping2. Forums
Im using SQL Server, ASP.NET and C#. Now the problem is that how do I configure the Databases. Whether I create new database for each or I marge the both things into one database. if i create saperate databases for each of the feature then users have to register for two times, first for forums and second for shopping. I dont want to do this...! I want users to register just for once.
____________Thanks in advNauman Ahmed

View 1 Replies View Related

Database Creation

Feb 6, 2007

I downloaded the sample database AdventureWorks from microsoft . When I run the download it created the data and log files under data folder in MSQLalong with other data and log files of master databases etc. However I do not see this database in SQLserver management studio. Can some one help me how to fix this so that I will be able to see this database in management studio.

I am downloading this for SQL server reporting purpose

View 1 Replies View Related

Database Creation

Mar 15, 2007

hi

if i open the management studio express and trying to create a database by right clicking the server name and trying in the new query window,im getting error as

CREATE DATABASE permission denied in database 'master'.

can anyone help me in rectifying this error?

Thanks in advance



View 4 Replies View Related

Database Creation With SMO In SSE

Aug 4, 2006

Hi there.

I tried finding any info regarding this approach and I can't find any, so here I am (again!).

I'm trying to create a database using SMO on a freshly installed SQL Server Express (not going through the advanced install, not going through the surface area configuration, so a lot of things are "wrong").

I get an error

- use SMO to try and create a database; this is the pseudo-code combo used:

1. create new Smo.Database object;

2. create new primary file group and data file for that database (using Smo.FileGroup and Smo.DataFile); add them to the database.

3. invoke Create(). catch exception with the following details:

Exception details:

Microsoft.SqlServer.Management.Smo.FailedOperationException was caught
HelpLink="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476"
Message="Create failed for Database 'NewDatabase'. "
Source="Microsoft.SqlServer.Smo"
Operation="Create"
StackTrace:
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.CreateImpl()
at Microsoft.SqlServer.Management.Smo.Database.Create()
at Penta.Core.Library.Sql.Classes.Penta_SqlDatabase.Create() in C:Documents and Settings[...]


InnerException:

{"Directory lookup for the file "C:\Documents and Settings\[...]\NewDatabase.mdf" failed
with the operating system error 5(Access is denied.).
CREATE DATABASE failed. Some file names listed could not be created. Check related
errors."}


Seems like user rights error.

Long story short, the only way the creation step works is if I change the Log on for the SQL Express service from the default Network Service to Local System (either through code or not).

Now, I know LocalSystem is not a wise idea, but it seems to be the only way.

I know it's probably something stupid, but what am I missing?

Thanks you in advance

View 3 Replies View Related

Creation Scripts From A Database

Apr 3, 2006

I would like to know the sql command to generate all the scripts of a database so that I can replicate the same database for testing purpose. For instance, I need those scripts to help me re-create the database itself and indexes, triggers, and stored procedures of it if possible.
I remember there was a command to display all these scripts in Sql but I forgot it. If someone knows it, please help. Thanks in advance.
blumonde

View 3 Replies View Related

Auomate Creation Of Database

Jan 16, 2001

Hi!All
I need to automate creation of database by passing name of database .Is it possible to this?If yes How to do ?

Thanks in advance for your your co operation.
Pradip

View 1 Replies View Related

Creation Of Database From Dump

Aug 29, 2006

Hello,

I have a SQL database dump with me. I would like to create a database using the dump. Could somebody help me with the steps?

Thanks :)

View 1 Replies View Related

Database Creation Script

Oct 15, 2015

I've never scripted a creation of a database and it's schema,I have started to put the script together and wondered if the following two scenarios were possible and if so could the following be possible and if so could you show me.

Scenario 1: Before the script runs it checks to see if a database of the same name exists. In this example the database name is "database1". If it does the script will stop and display a message along the lines of "You are trying to create a database, which name already exists. Please either drop or rename the current database and rerun this script."

Scenario 2:The more difficult one I think. Is that it checks to see if "database1" exists. If it does it displays a message along the lines of "The database you are trying to create already exists. Please confirm that you either want to Drop the Database" You then press a key on the keyboard to continue the script and the database is dropped. It will then tell you to rerun the script in order to create the "database1" database. Or you could even give them the option to either drop the database or rename it with "_todatdate" at the end of it, but if you can get the script to do different things with different keyboard strikes?

DATABASE1 CREATION SCRIPT
Author: Ryan Keast

The following script creates a DATABASE1 database.
*/
/*DATABASE1 database creation */

[code]....

View 1 Replies View Related

Database Creation Problem

Jul 31, 2007

the following msg appears whn i try to create a new database in Microsoft Sql Server Management Studio Express.
I m on Vista Basic and using a administrator account...plz help.... i have my project whose backend is SQL 2005.

------------------------------------------------

TITLE: Microsoft SQL Server Management Studio Express
------------------------------

Create failed for Database 'timepass'. (Microsoft.SqlServer.Express.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

------------------------------

CREATE DATABASE permission denied in database 'master'. (Microsoft SQL Server, Error: 262)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

View 4 Replies View Related

[help] Scripted Database Creation

Jul 13, 2007

Hi all :)My apologies if I posted in the wrong groups, but I just jumpedin MS SQL waters, so any guidance will be appreciated.What I'm trying to do is the following process:[1] present operator with a web page (script)[2] once filled with db name and username, script will create..sql file[3] osql.exe will be called with, i presume, -i file.sql andcreate a databaseI have limited SQL knowledge, but I got the information fromEnterprise Manager when I ran 'All Tasks -Generate SQLScript' on how the .sql file should look like.I realized what are the commands that would create a fresh DB(I ran this for newly created DB), and figured my .php scriptshould create such a file.It's fairly basic, and I'm almost sure all of you know howoutputed .sql file looks like, but anyway here it is:Script is called with parameters 'six' as database name and'magarac' as user name:---------------------------------------------------------------IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name= N'six')DROP DATABASE [six]GOCREATE DATABASE [six] ON (NAME = N'six_Data', FILENAME = N'E:Databasepathsix_Data.MDF' , SIZE = 1, MAXSIZE = 20,FILEGROWTH = 10%) LOG ON (NAME = N'six_Log', FILENAME = N'E:Databasepathsix_Log.LDF' , SIZE = 1, MAXSIZE = 20, FILEGROWTH= 10%)COLLATE SQL_Latin1_General_CP1_CI_ASGOexec sp_dboption N'six', N'autoclose', N'false'GO....use [six]GOif not exists (select * from dbo.sysusers where name =N'guest' and hasdbaccess = 1)EXEC sp_grantdbaccess N'guest'GOif not exists (select * from dbo.sysusers where name =N'sinisam')EXEC sp_grantdbaccess N'magarac', N'magarac'GOexec sp_addrolemember N'db_owner', N'magarac'GO---------------------------------------------------------------I managed to get an exact replica of .sql file that EnterpriseManager created. It leads me to believe that this way ofautomated database creation is indeed possible.Really sorry for making you to go through all this text, butafter I get a green light on this from you guys, I'll have abit more problematic question.Is there any reason why this should not be used, or would fail?Thanks in advance :)P.S.Just as a heads-up, next part of my problem is automatedcreation of new MS SQL server login to use with new DB.

View 3 Replies View Related

Creation Of Reporting Database

Jul 20, 2005

We have a production database, but due to the crippling load of somereporting tools, we are looking to have a separate reporting database.Due to it's nature, the reporting database doesn't need to be as upto date as the master, perhaps it could be refreshed every evening?What I wish to know is the best way to go about this. Replicating awhole database seems excessive as there are 7000+ tables and we don'tneed it so closely matching the production database. Log shippingalso seems out as we need the reporting database to be highlyavailable and if we keep applying transaction logs ever 15 minutes orso, we need to kick all the users out.Is there a way of scripting or automatically getting SQL Server 2k tocopy over the last full backup it did and apply this to anotherserver? Also if we used this method, what would happen to the usersstored in the database? Would I have to keep re-adding them after theupgrade?Is there a better way to tackle this problem? All help gratefullyreceived. We are running SQL Server 2000 Enterprise Edition on aWindows 2000 Server machine.Thanks.

View 3 Replies View Related

Database Creation Using VB.NET Code

Jul 6, 2006

Hello.

I think its silly question but i expect some solution .

Is there any way to create sql sever database by using VB.NET code ? I have to create database,tables,sps and also transfer the data from one database to newly created database.

Please, if somebody have some solution then guide me in detail.

Thanks in adv.

View 12 Replies View Related

Database Script Creation

May 30, 2006

In the paste I have used SQL2000 to create db from the Query Analyser. In SQL2005 I can't see Query Analzyer but found under programs --> Microsoft SQL Server 2005 --> Configuration Tools --> Reporting Services Configuration --> Database Setup. It creates a database and I can connect to it from VS.NET. Here is my dilema, I was provided SQL scripts to create tables, stored procs etc. Where and how do I run these scripts to create these things in my newly create db.

Also how do I remove a db in SQL2005?

View 3 Replies View Related

Database Creation For Personl Starter Kit

Jun 9, 2005

I am unable to create the personal.mdf when I run my homepage.  I get the following error
Failed to generate a user instance of SQL Server due to a failure in
starting the process for the user instance. The connection will be
closed.
I am new at this stuff and any help will be welcomee. .
thanks
Seth

View 4 Replies View Related

SQL 2005 Express Database Creation

Dec 4, 2006

Hi guys,

i`ve just downloaded a copy of MS SQL 2005 Express. I'm relatively new to programming and DB management.

can i create a DATABASE using SQL 2005 Express itself? Or do i need other software?

View 1 Replies View Related

Need To Prevent Database Assembly Creation

Oct 12, 2006

On certain servers, I don't want developers to be able to create assemblies.
Unfortunately, the command

sp_configure 'clr enabled', 0

only prevents the CLR-type from being executed, not its creation.

I am unable to rename nor put triggers on
sys.assemblies,
sys.assembly_modules,
sys.assembly_files, and
sys.assembly_references .

I would prefer the user know the boundaries well before implementation.

Has anyone succeeded at this?

View 3 Replies View Related

Default Permissions On Creation Of New Database

Jan 23, 2008

I notice when I create a new database within my SQL Server that the
permissions for the new database automatically adds a user (Who is configured
as sysadmin) with dbo permissions to this database.

Both within the login properties of the select user (User mapping) is listed
as Default Schema, dbo and within the permissions of the database listed as
user with connect permissions.

I have other users configured as sysadmin and they do not get this rights
(They are not expliticly listed within user mapping with dbo or permissions
as user within the database).

I've inherited this system and wonder if the user has somehow changed the
new database procedure so it changes the default permissions of new databases.

Any way to check what he's done, I can see no differences between him and
the other sysadmins but he's definatly specifically listed as a dbo on all
new databases.

Although I don't mind him having access, he's a sysadmin after all, I'd like
to make it uniform thoughout the system, i.e. using the inhertited
permissions rather than specific permissions that seem to be created when the
new database is created.

Any ideas?

Flubster

View 1 Replies View Related

Database Creation From Inside Of Visual C#

Dec 19, 2006

When I create a database from inside of Visual C# Express, why can't I view it with the manager from the SQL Server Express Edition? I mean, it does not appear at all. Is there any problem?

View 5 Replies View Related

Changing Default Database Creation Location....

Aug 7, 2002

I have installed my modell database onto c:mssql7data...

How do I now change the properties of this so that when someone creates a database, the path it will get created to is set to d:
I thought that I could just move model, but it seems that this isn't possible.

Any advice?

thanks

derek

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved