我自己解决!问题是我的所有存储过程都有一个带有 NULL 值的扩展属性!!!
所以要解决这个问题应该更新它们并为它们生成 Not NULL 值。
下面的示例代码将使用其扩展属性中的 NULL 值更新存在的整个存储过程的所有值(只需将 替换为YOUR_EXTENDED_PROPERTY_NAME
您自己的具有 NULL 值并且应该更新的扩展属性名称):
DECLARE @Query AS NVARCHAR (MAX);
DECLARE c CURSOR FOR
----------------------------------------------------
SELECT 'begin try EXEC sys.sp_updateextendedproperty @name=''YOUR_EXTENDED_PROPERTY_NAME'', @value='''' , @level0type=''SCHEMA'',@level0name='''
+ schemaName + ''', @level1type=N''PROCEDURE'',@level1name=N''' + spname + ''' End try Begin catch End catch'
FROM (
SELECT Ob.name spname,
EX.name extended_name,
sch.name AS schemaName,
EX.value
FROM sys.extended_properties AS EX
JOIN sys.objects AS Ob ON Ob.object_id = EX.major_id
JOIN sys.schemas AS sch ON sch.schema_id = Ob.schema_id
WHERE Ob.type = 'P'
AND EX.value IS NULL
) t;
----------------------------------------------------
OPEN c;
FETCH NEXT FROM c
INTO @Query;
WHILE @@fetch_status <> -1
BEGIN
EXECUTE sp_executesql @Query;
FETCH NEXT FROM c
INTO @Query;
END;
CLOSE c;
DEALLOCATE c;
问题是,为什么微软让插入 NULL 值然后Object reference not set to an instance of an object.
在它们上面得到错误!!!