Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor just dies in SP
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00662658
Message ID:
00662685
Views:
14
>This all works and runs as fast as I could possibly expect. There are better ways and faster ways to do this, but because of our security and [what I consider] arbitray DBA policies, I have no other options for this particular case.
>
>If you can be more specific about what you are doing and maybe some sample code, I may be able to provide better help.

Actually the metadata I am getting is generated via Java Beans. It has the label text the the user can change as well as the column details.

Here is the crud:
if @count =1
begin
set @cmd2 =''
set @cmd2 = 'CREATE TABLE '+ @table +'
([Pt_Id] [numeric](14, 0) NULL , [Dx_Id] [numeric](8, 0) NULL , '
end

else
-- @count >1 so start with an ALTER Table
begin

Set @cmd2 = 'ALTER TABLE ' + @table + ' Add '


end

declare @column_extra varchar(10), @snomed_extra int

set @column_extra =
case when right(@column_name,2) = '_A' or right(@column_name,2) = '_B'
then substring(@column_name,len(@column_name)-1,2) else ''
end
set @column_extra =
case when @snomed_indicator= 1 then '_Code' else @column_extra
end

set @column_extra =
case when @snomed_indicator= 2 then '_Type' else @column_extra
end
--Missing the "_ID" desigantion in questions
set @column_extra =
case when @Column_type= 'LONG' then '_ID' else @column_extra
end

-- Run of extra somed column
set @snomed_extra =
case when @snomed_indicator= 2 then 1 else 0
end



set @cmd2 = @cmd2 + ' [' + @column_comment + @column_extra
+'] ' +
case @column_type
when 'STRING' then 'VARCHAR(100) '
when 'CHAR' then 'VARCHAR(100) '
when 'DOUBLE' THEN 'NUMERIC( 9,5) '
when 'INT' THEN 'int '
when 'DOUBLE2' THEN 'NUMERIC( 9,5) '
when 'STRING' tHEN 'VARCHAR(300) '
when 'DATETIME' then 'smalldatetime '
when 'DOUBLE3' THEN 'NUMERIC( 9,5) '
WHEN 'LONG' THEN 'VARCHAR(100) '
WHEN 'DATE' THEN 'SMALLDATETIME '
end
+ ' NULL '+
case when @count=1 then ' ) ' else ' ' end

print ' '+@cmd2

execute (@cmd2)


if @snomed_extra =1
begin

Set @cmd2 = 'ALTER TABLE ' + @table + ' Add '

set @cmd2 = @cmd2 + ' [' + @column_comment + '_Text'
+' ] varchar(250) NULL '

print @d +'---'+ @service_name+ ' '+ @table_name+' '+ @column_comment

Print @cmd2

exec (@cmd2)

set @count = @count+1

end


exec ('use ds_dmb')
set @count = @count+1


FETCH NEXT FROM service_cursor_columns
INTO @column_name, @column_type , @column_comment, @Lookup_table ,@snomed_indicator , @column_order



That's all I'm doing <eg>.
Previous
Reply
Map
View

Click here to load this message in the networking platform