Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
waleed_cs2000
Starting Member
14 Posts |
Posted - 2009-06-17 : 11:58:20
|
| hiI have this script to get the default value of a column dynamically ,it works for most columns types except for varbinary that has default hex value, when @t = 0x0343 ,then @v =0x03note that I had to use nvarchar(4000) at first because INFORMATION_SCHEMA.COLUMNS forces me to do so, can you help me? thanks in advance-----------------------------------create table #temp(column_name sysname,column_def nvarchar(4000))insert into #temp SELECT column_name,column_defaultFROM INFORMATION_SCHEMA.COLUMNSwhere table_Name ='table_1'declare @t nvarchar(4000)set @t=(select column_def from #temp where column_name='c_varbin')set @t = replace (@t ,'(','')set @t = replace (@t ,')','')select @tdeclare @v varbinaryset @v = convert ( varbinary,@t)select @vdrop table #temp----------------------------------- |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-17 : 12:39:07
|
not sure if thats cause, but you've not specified length while convert . try giving length in last set statementset @v = convert ( varbinary(10),@t) |
 |
|
|
waleed_cs2000
Starting Member
14 Posts |
|
|
|
|
|
|
|