Re: Running SQL script through VB

From: BONTZ (BONTZ_at_discussions.microsoft.com)
Date: 08/31/04


Date: Mon, 30 Aug 2004 19:21:04 -0700

Hi Joseph,

 I am connecting through a default username (windows authentication) and my
setup is creating tables and users. So connection is not a problem.

The error I am getting while running a script (generated by SQL server
enterprise manager) was " 'Create Procedure' statement should appear on the
top of the module". I cut pasted the Create procedure code to the top of
script. Now the error is

create procedure dbo.dt_adduserobject
as
        set nocount on
        /*
        ** Create the user object if it does not exist already
        */
        begin transaction
                insert dbo.dtproperties (property) VALUES ('DtgSchemaOBJECT')
                update dbo.dtproperties set objectid=@@identity
                        where id=@@identity and property='DtgSchemaOBJECT'
        commit
        return @@identity

SET QUOTED_IDENTIFIER OFF

SET ANSI_NULLS ON

GRANT EXECUTE ON [dbo].[dt_adduserobject] TO [public]

SET QUOTED_IDENTIFIER ON

SET ANSI_NULLS ON

Can you help me out ?

Thnx
 "A use database statement is not allowed in a procedure or trigger"

whereAs in procedure I am nowhere using USE DATABSE statment. The code of my
create procedure is :

 

"Joseph Vinoth" wrote:

> Hi,
>
> I need two info from you to help
>
> what is the error you are getting ?
> which sql user are u connecting?
>
> try with system abdministrator user name that is sa and the password
>
> Regards
> Joseph Vinoth
>
>
> "Ken Tucker [MVP]" wrote:
>
> > Hi,
> >
> > http://www.microsoft.com/downloads/details.aspx?FamilyID=6e9a7403-c4ba-4d98-bb0b-2c9d6414071f&DisplayLang=en
> >
> > http://www.red-gate.com/sql/sql_packager.htm
> >
> > Ken
> > -------------------------------
> > "BONTZ" <BONTZ@discussions.microsoft.com> wrote in message
> > news:06865DBB-B66B-4A24-9FD4-2E2E54B30A34@microsoft.com...
> > Hi all,
> >
> > I have generated a huge SQL script which installs the whole database
> > starting from creating database, tables,creating procedures, creating users
> > and everything thats required by my application.
> > Now i am using a custom action to install that database on my machine by
> > a deployment project for my application. It creates database and tables but
> > throws exceptions while creating procedures.
> > I am putting all the SQL code in a single txt file and reading it to
> > execute query.
> >
> > 1. Can I use a single file for all operations ?
> > 2. What I need to do for the procedures and create users ?
> >
> > Thnx
> >
> >
> >



Relevant Pages

  • Re: Cannot Open SQL Server Table in Access.ADP File.
    ... I dont think that SQL Server will take 'veiw dependencies' into effect; ... Generate Script Wizard did not work on my original database, ... After fixing some of my tables and a few stored procedures and views, ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Enterprise Manager Newbie Question
    ... a SQL backup is not a simple copy of the database files. ... Is it possible to write a script that one could run from a workstation and ...
    (microsoft.public.sqlserver.tools)
  • Re: SQL Security
    ... except I'm having problems making it work in a script. ... ;Set properties of DB objects and open connection to database ... > from Books Online (within the SQL Server program group): ... > communicate with SQL Server. ...
    (microsoft.public.sqlserver.server)
  • Re: Vista hosting XPe tools/db
    ... Are you running this script on the machine that actually has the SQL server ... machine hosting the database. ... i don't know if you can install a second instance of SQL ...
    (microsoft.public.windowsxp.embedded)
  • Re: FORCE DB Corruption
    ... This script from Sharon Dooley should do the trick - be careful with it ... I haven't tried it on SQL 2000, ... /* this script works on a database that is a copy of pubs. ... How can I force a database to become corrupt to a point> that DBCC CHECKDB will report errors? ...
    (microsoft.public.sqlserver.server)