Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 stored procedure required

Author  Topic 

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2009-06-23 : 07:41:18
hi i am having a table EMRALLERGIES where i am using a column which is bit and now i want to change the data type to numeric.fro that i am using like this.


ALTER TABLE EMRALLERGIES ADD TEMP_STATUS NUMERIC(1,0)
GO
UPDATE EMRALLERGIES SET TEMP_STATUS = STATUS
GO
ALTER TABLE EMRALLERGIES DROP CONSTRAINT DF__EMRAllerg__STATU__7B7B4DDC
GO
ALTER TABLE EMRALLERGIES DROP COLUMN STATUS
GO
ALTER TABLE EMRALLERGIES ADD STATUS [NUMERIC](1,0) DEFAULT 1
GO
UPDATE EMRALLERGIES SET STATUS = TEMP_STATUS
GO
ALTER TABLE EMRALLERGIES DROP COLUMN TEMP_STATUS
GO

but the default constraint name is differing all the time.so i want a procedure for this.can anyone help me out in this?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-23 : 08:50:22
You can name your default contraint.
See Books Online for more information.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -