1

Closed

Invalid "DELETE DEFAULT" generated SQL script

description

The following generated SQL code fragement is invalid at case-sensitive MS SQL database:
--DELETE DEFAULT
select 'ALTER TABLE [dbo].[Address] DROP CONSTRAINT ' + [name] as 'sql' 
into #t 
from sysobjects 
where id IN (
select sc.cdefault 
FROM dbo.sysobjects SO INNER JOIN dbo.syscolumns SC ON SO.id = SC.id 
LEFT JOIN sys.default_constraints SM ON SC.cdefault = SM.parent_column_id 
WHERE SO.xtype = 'U' and SO.NAME = 'Address' and SC.NAME = 'CountryId')
declare @sql [nvarchar] (1000)
SELECT @sql = MAX([sql]) from #t
exec (@sql)
drop table #t
The selected column has the unrecognized table alias "sc.default" vs. "SC.default":
...
select sc.cdefault 
FROM dbo.sysobjects SO INNER JOIN dbo.syscolumns SC ON SO.id = SC.id 
...
should be
...
select SC.cdefault 
FROM dbo.sysobjects SO INNER JOIN dbo.syscolumns SC ON SO.id = SC.id 
...
Closed Aug 8, 2013 at 5:51 PM by codetools
Fixed in the next version.

comments

codetools wrote Aug 8, 2013 at 5:51 PM

I think this is only an issue in case sensitive database. In any case it will be fixed in the next version.

wrote Aug 8, 2013 at 5:51 PM

motlajs wrote Aug 13, 2013 at 8:17 PM

Yes, it is the case-sensitive database issue.