SQL Server : ALTER COLUMN only if existing column has a smaller length
<p>I am trying to create a script which will alter a column only if it is not of the correct size. Something like this.</p>

<pre><code>IF NOT EXISTS (SELECT COL_LENGTH('dbo.TSC701_OCT_CONTEXT', 'sql_stmt') = 1000 )
BEGIN
    ALTER TABLE dbo.TSC701_OCT_CONTEXT 
        ALTER COLUMN sql_stmt VARCHAR(1000)
END
</code></pre>

<p>Sorry for the screwed up syntax</p>