convert output of sp_executesql to float values ?

  • I am trying to compare a column value (float) with 2 computed float values.

    I want to compare the result of gridsize to see if its value is in between min_spidx_size and max_spidx_size.

    I can generate the sql to obtain said values, but I don't know how I can go about converting the results of the calls to sp_executesql to floats and storing them in my declared float variables.

    How is such a thing done ? Seems rather elementary. I think its a question of Books Online returning too many paths to go down.

    use fortbend

    DECLARE @fulltablename varchar(35),@f_table_owner varchar(30),@geomtable_name varchar(5)

    DECLARE @minsize_sql nvarchar(100), @maxsize_sql nvarchar(100),@curr_gridsize_sql nvarchar(100)

    DECLARE @min_spidx_size float(10),@max_spidx_size float(10),@gridsize float(10)

    DECLARE featureLayer_Cursor CURSOR FOR

      select f_table_schema, g_table_name from sde.SDE_geometry_columns where f_geometry_column = 'SHAPE'

    OPEN featureLayer_Cursor

    FETCH NEXT FROM featureLayer_Cursor INTO @f_table_owner, @geomtable_name

    WHILE @@FETCH_STATUS = 0

        BEGIN

     select @fulltablename = @f_table_owner+'.'+@geomtable_name

     select @minsize_sql = N'SELECT (3 * avg(((emaxx - eminx) + (emaxy + eminy) / 2))) min_avg_edge from '+@fulltablename

     select @maxsize_sql = N'SELECT (5 * avg(((emaxx - eminx) + (emaxy + eminy) / 2))) max_avg_edge from '+@fulltablename

     select @curr_gridsize_sql = N'SELECT gsize1 from sde.SDE_Layers where layer_id = right('''+@geomtable_name+''',1) and spatial_column = ''SHAPE'''

     EXEC sp_executesql @minsize_sql

     EXEC sp_executesql @maxsize_sql

     EXEC sp_executesql @curr_gridsize_sql

    select @min_spidx_size = CAST(EXEC sp_executesql @minsize_sql)  /*barf*/

     FETCH NEXT FROM featureLayer_Cursor INTO @f_table_owner, @geomtable_name

        END

    CLOSE featureLayer_Cursor

    DEALLOCATE featureLayer_Cursor

    GO

  • select @minsize_sql = N'SELECT @min_spidx_size = (3 * avg(((emaxx - eminx) + (emaxy + eminy) / 2))) min_avg_edge from '+@fulltablename

    exec sp_executesql @minsize_sql , N'@min_spidx_size float OUT' , @min_spidx_size = @min_spidx_size OUT

    Repeat for other variables/queries

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply