Re: Run script from ADO components - if possible



Hi,
This will be a problem.
I want to create a database at runtime, so I need to run the script:
-create database
-use that database
-create table 1
-create table 2
- .....
-create table N

-insert lookup table data

In addition, if I separate each create table statement, I need to put all
those lines in one line ?


"Mikael Eriksson" <micke314@xxxxxxxxx> wrote in message
news:461c7caf$1@xxxxxxxxxxxxxxxxxxxxxxxxx
Alan T skrev:
I want to run scripts like:

CREATE DATABASE [Employee]
COLLATE Latin1_General_CI_AS
GO

exec sp_dboption N'Employee', N'autoclose', N'false'
GO

exec sp_dboption N'Employee', N'bulkcopy', N'false'
GO

CREATE TABLE [dbo].[Table_Employee] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [varchar] (255) NULL ,
[Address] [varchar] (255) NULL
) ON [PRIMARY]
GO

I tried to put these strings into TADOQuery but it doesn't work.




Hi!
Here you have four statements separated by *GO*.
You have to execute one statement at a time.

regards

/Micke


.



Relevant Pages

  • Re: Cant get global config data and KB 900499 doesnt help
    ... The account you use to create the database MUST have the following rights on ... DECLARE @AdminVSAccount nvarchar ... DECLARE @ContentVSAccount nvarchar ... EXEC sp_grantlogin @ContentVSAccount; ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Permission in database
    ... You can create database roles and assign object permissions to these ... EXEC sp_addrole 'Administrators' ... GRANT SELECT, INSERT, UPDATE, DELETE ON Sales TO Administrators ...
    (microsoft.public.sqlserver.security)
  • Re: stored procedure
    ... Seems you can't have a variable for the database name in CREATE DATABASE. ... the whole CRE¤ATE DATABASE command in a variable and use EXECto execute the statement. ... But why do you want to create a database from inside a stored procedure? ... >> is done inside EXEC so it is in its own scope. ...
    (microsoft.public.sqlserver.server)
  • Re: Database Ownership
    ... can I declare database ownership on more than one ... believe the performance difference is noticeable for most applications. ... then grant select permissions on the views. ... EXEC sp_changedbowner 'MyLogin' ...
    (microsoft.public.sqlserver.security)
  • RE: help required for DBI script!
    ... Regards, ... Marc Torres Alvarez ... I have this script that keeps bugging me with an Oracle error ORA-00942 ... system_events WHERE database = 'BISP.emea.fedex.com')) b ...
    (perl.dbi.users)