Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:46:22+00:00 2026-06-01T14:46:22+00:00

I am having .sql (sybase) file which creates the table i.e. Create_table_mytable.sql But before

  • 0

I am having .sql (sybase) file which creates the table i.e. “Create_table_mytable.sql”

But before creating the table it check of the existing table and drops the same.

here is how scripts looks like: –

setuser 'dbo'
go 


    IF EXISTS (SELECT 1 FROM sysobjects o, sysusers u WHERE o.uid=u.uid AND o.name = 'mytable' AND u.name = 'dbo' AND o.type = 'U') 
    begin
        print 'dropping mytable'
         drop table   mytable   
        print 'dropped mytable'  
    end
go    
    IF NOT EXISTS (SELECT 1 FROM sysobjects o, sysusers u WHERE o.uid=u.uid AND o.name = 'mytable' AND u.name = 'dbo' AND o.type = 'U')
    begin       
        create table mytable (
                id numeric(9,0)     IDENTITY ,
                description             varchar(50)     not null
                )

                GRANT SELECT ON dbo.mytable TO my_user

                GRANT INSERT ON dbo.mytable TO my_user

                GRANT DELETE ON dbo.mytable TO my_user
    end
    go


end
go

setuser  
go 

Here is the contents of cmd file: –

@ECHO ON

ECHO ">> START <<  mytable.sql" >> %LOG%
%SQL% -S %SERVER% -U %USER% -P %PWD% -D %DB% -i mytable.sql >> %LOG%

@ECHO OFF

Here is the contents of log file: –

">> START <<  mytable.sql" 
Msg 102, Level 15, State 1:
Server 'myserver', Line 14:
Incorrect syntax near 'go'.
">>> SYBASE SCRIPT COMPLETE <<< " 

Note: the same scripts runs properly if executed using Sybase Intrective SQL or ASE Tools.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:46:23+00:00Added an answer on June 1, 2026 at 2:46 pm

    Fine I got the answer. Here is what I missed to write after dropping table: –

    use db
    go 
    
    setuser 'dbo'
    go
    
    
    IF EXISTS (SELECT 1 FROM sysobjects o, sysusers u WHERE o.uid=u.uid AND o.name = 'mytable' AND u.name = 'dbo' AND o.type = 'U')
    begin
    print 'dropping mytable'
        drop table mytable
        print 'dropped table - mytable'
    end
    go 
    
    IF (@@error != 0)
    BEGIN
        PRINT "Error CREATING table 'mytable'"
        SELECT syb_quit()
    END
    go
    
    
    IF NOT EXISTS (SELECT 1 FROM sysobjects o, sysusers u WHERE o.uid=u.uid AND o.name = 'mytable' AND u.name = 'dbo' AND o.type = 'U')
    begin       
        create table mytable (
                id numeric(9,0)     IDENTITY ,
                description             varchar(50)     not null
                )
    
    
                GRANT SELECT ON dbo.mytable TO my_user
    
                GRANT INSERT ON dbo.mytable TO my_user
    
                GRANT DELETE ON dbo.mytable TO my_user
    
    end
    go
    
    setuser  
    go 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server is it possible to perform table partition without having to recode
Having this SQL tables for a tagging system: CREATE TABLE tags ( id SERIAL
Can COMMON Table expressions be used to avoid having SQL Server perform the following
I'm having an sql error that i can't work out. I have to update
New to MVC3 Razor - linq to sql having spent some time trying to
I'm having problems installing SQL Server as prerequisite on my Visual Studio Setup application
I having trouble in my sql query .Please see my example As u see,
I am having some problems turning the SQL below into a Zend Db query.
I'm having a problem with some T-SQL in a SP on SQLServer 2005 comparing
I'm having some trouble with an SQL statement that have to find the number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.