Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alter Table Syntax Problem 1

Status
Not open for further replies.

sivaram101

Technical User
Nov 30, 2005
1
IN
Hello ,
I am having a problem related to Alter table syntax in MS SQL Server .
What I want to do is in a single alter table statement I want to add as well as modify columns in a table.

For E.g.
alter table testtable add fld1 numeric(10),
alter column fld2 numeric(15)
But I am getting an error.are these kinds of statements possible in MSSQL server ?I was able to do so in Oracle.I just wanted some confirmation or examples of whether this is possible in MS SQL Server also.
Fast Help would be extremely appreciated.
Thanks,
Anand

 
Try the following on Query Analyzer:
Print 'Create Table'
CREATE TABLE doc_exa ( column_a INT)
GO
EXEC sp_help doc_exa
GO
PRINT 'Add New Colum'
ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL
GO
EXEC sp_help doc_exa
GO
PRINT 'Alter New Colum'
ALTER TABLE doc_exa ALTER COLUMN column_b VARCHAR(20) NOT NULL
GO
EXEC sp_help doc_exa
GO
DROP TABLE doc_exa
GO
I hope this will help you AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top