Link to home
Start Free TrialLog in
Avatar of MadIce
MadIce

asked on

return table name with query results from stored procedure

I am calling and running the following store procedure from vb.net.

CREATE   PROCEDURE dbo.uspSelectQueries  @msg1 varchar(3000) output
AS
Declare cSteps cursor  for
select New_Sql, table_Name, comment  from tblTotal
declare @SQL VARCHAR(500),  @tblName VARCHAR(300)

open cSteps
FETCH next from cSteps into @Sql, @tblName
while @@fetch_status = 0
begin
     exec(@sql)
    fetch next from cSteps into @sql, @tblName
     
end
close csteps
deallocate csteps
GO

the field New_Sql is a select statement with in my table and is ran with the exec(Qsql) statement which returns the results which I load to different datagrids. The problem I have is the field Table_Name is the name of the results. I want to name the table in the datagrid with this name. So the first query results should also pass Table_Name so I can set the table name in the grid.  The Only thing I can think of doing is storing passing the field Table_Name into a variable and using output parameter. But than I would have to substr or something like that to filter out each table name. Can I use an array within a strored Procedure or is there a way to pass the Table_name with the exec?  Thanks
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MadIce
MadIce

ASKER

Well that was cleaner than if I used output parameter and it works. Thanks Again...
Glad to hear that it worked.
Were you able to resolve this issue?
Avatar of MadIce

ASKER

I accepted this answer before...at least I thought I did.