SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL SERVER gurus please help!!

    SQL SERVER gurus please help!!

    I have SQL database on a remote server. Basically I need to insert a new column into a table that is already populated with data.

    I don't have permission to access the db through enterprise manager. I can, however, use T-SQL in Query Analyser to interact with database.

    Would I need to write a script to do it?

  2. #2
    SitePoint Evangelist Umair.ms's Avatar
    Join Date
    Sep 2000
    Location
    Lahore, Pakistan
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont have much experience of SQL Server. But I think you can right a stored procedure to do the job. Although I know how to write and work with stored procedures but I am not sure about this in this situation.
    TinyPlanet.org
    Discuss and Debate World Events, Politics and Religion.
    Interact and Share your Views with People around the Globe.

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll need to use the ALTER TABLE command.

    Code:
    ALTER TABLE <tablename>
    ADD <columnname> <datatype> NULL
    If you use NOT NULL you'll need to specify a default value.

    Code:
    ALTER TABLE <tablename>
    ADD <columnname> <datatype> NOT NULL DEFAULT <defaultvalue>

  4. #4
    SitePoint Addict kevin_tremblay's Avatar
    Join Date
    Jul 2001
    Location
    Boston Area (North shore)
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will confirm what shane said you need to do the ALTER command, only thing is you will need to have the permissions to do this. I assume you do right?
    Kevin Tremblay-- Sys Admin
    work: kevin_tremblay@hsgmed.com
    "The object of the journey is not to arrive."

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks Shane

    Yep it worked !!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •