I am in process of changing quite a lot of tables' column type (migrating from int to float) to accommodate higher values.
Most of which columns have bindefault zero or space. Applied like so
exec sp_bindefault zero ,'table.column';
To alter the column I will have to unbind column using
exec sp_unbindefault 'table.column';
Given this has to be done for many table and a lengthy stored proc I am hoping to see if we can use variables to execute above ?
I have tried something like following, which results in errors like so,
#1
exec sp_unbindefault @table.@colunn;
or
exec sp_unbindefault [table].[column];
results in,
SQL Error [102] [S0001]: Incorrect syntax near '.'.
#2
exec sp_unbindefault '@table'+'.'+'@column';
Results in
SQL Error [102] [S0001]: Incorrect syntax near '+'.
So, is it possible to pass a values bonded to a variable when executing sp_bindefault/sp_unbindefault?
Example of stored proc
BEGIN
declare @table varchar(200);
declare @column varchar(200);
declare @err nvarchar(4000);
set @table = 'abc';
set @column = 'xyz';
PRINT 'table :' + @table;
PRINT 'column : ' + @column;
exec sp_unbindefault '@table'+'.'+'@column';
---- other processing
exec sp_bindefault zero ,'@table'+'.'+'@column';
END
Thanks