views:

211

answers:

5

Is there any option in sql server 2005 management studio to change columns in a table by hand and by the sql commands alter table or insert into.

If yes, then could someone please show how or link to some instructions?

A: 

In object explorer, if you navigate from

* [Server]
  * Databases
    * [Specific DB Name]
      * Tables
        * dbo.[Tablename]

And then right click on table, the context menu has a choice called "Edit Top 200 Rows". Is that what you're looking for?

Michael J Swart
I think you are using Sql Server 2008? This is not an option in Sql Server 2005
astander
It was called Open Table in SQL Server 2005. Thanks to my vocal complaining and plenty of votes on Connect, they split it out into two different menu items (so that when you just want to select, you don't place unnecessary locks on the table, and you no longer get the *whole* table (ever try it on a billion row table?)). Anyway, get 2008 client tools; why continue to use the much more broken older version? You can still manage 2000 and 2005 instances with the 2008 tools.
Aaron Bertrand
+1  A: 

Not sure what you are asking, you can right click the table and open it and manually enter data. If you need to edit it, just right click it and choose Design Table. If you want to issue a change to it via SQL you can issue an ALTER TABLE MYTable.

JonH
A: 

If you want to manually add or edit a row. right click the table and click open. this will bring back the table with contents wich can then be added to or edited.

You can change the structure of the table by clicking Design, rather.

You can then also view the generated script of these changes if you like.

astander
A: 

Open up your Database > Tables. Right-click on your table and select Edit. This will bring you to your straight SQL syntax entry.

Or you can go to Databases > Tables, Right-click on your table and select Design. This will bring you to a simple GUI to modify your table.

0A0D
+2  A: 

Sure you can.

If you want to rename columns you'll need to use sp_rename. Check this link out:

http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/

HOWEVER, there's a big caveat: if you use this column from within any stored procedures, functions, views, etc., they're all going to break so I'd recommend using a tool such as SQL Refactor from Red Gate Software (disclaimer: yes, I work for Red Gate) which will rename the column along with all its usages elsewhere in your schema. You can find out more and download SQL Refector from:

http://www.red-gate.com/products/SQL_Refactor/index.htm

(The tool comes with a 14-day fully functional free trial, if you want to give it a whirl.)

If you want to perform other actions, such as adding or removing columns, you'll need to use the ALTER TABLE statement (lots of examples at the bottom of this page):

http://technet.microsoft.com/en-us/library/ms190273%28SQL.90%29.aspx

If you want to change the data in a column you'll need to use the UPDATE statement:

http://technet.microsoft.com/en-us/library/ms177523%28SQL.90%29.aspx

Hopefully that helps, but if I've misunderstood, please let me know.

Bart Read
UPDATE and ALTER TABLE are much more reliable and bug-free than the UI counterparts. Learning the syntax may seem "hard" but it's better than the potential pitfalls of the voodoo behind SSMS (especially the 2005 version).
Aaron Bertrand
I totally agree. Learning the SQL will also improve your general knowledge and understanding of SQL Server.
Bart Read