Hi marabu,
DANKE! Hat perfekt geklappt. Statement insgesamt nun so:
SQL-Code:
CREATE PROCEDURE [DBO].[GetConstraintName] (
@tablename sysname,
@columnName sysname,
@constraintName sysname OUTPUT
)
AS
SELECT @constraintName = o1.name
FROM sysobjects o1
INNER JOIN syscolumns c
ON o1.id = c.cdefault
INNER JOIN sysobjects o2
ON o1.parent_obj = o2.id
WHERE (o2.name = @tablename)
AND (c.name = @columnName)
Declare @conName sysname
exec GetConstraintName '
Invoice', '
Payed', @constraintName = @conName
OUT
declare @
sql nvarchar(1024)
set @
sql = '
ALTER TABLE [Invoice] DROP CONSTRAINT ' + @conName
exec(@
sql)
ALTER TABLE [Invoice]
DROP COLUMN Payed;
DROP PROCEDURE GetConstraintName;