question

prasad.nyalapatla avatar image
prasad.nyalapatla asked

how to get table names from sp

hi, i wrote a one storedprocedure like crate procedure sp_test1 as begin select col1,col2,col3 from mo_users select col1,col2,col3,col4 from mo_masters end if i execute above sp from front end(dotnet), in dataset fills with 2 tables as table,table1 but i want names as `mo_users`,`mo_masters` here is any possible ways to send table names from sp to frontend dataset thanks....
stored-proceduresado.net
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image Fatherjack ♦♦ commented ·
isnt sending table names back to a web ui exposing yourself to attack?
1 Like 1 ·

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered
Not as far as I know, at least, not easily without sending further result sets. Or by changing your SP to send back: ... SELECT 'mo_users' AS tablename, col1, col2, col3 from mo_users ... You might be able to do something with sending back messages as well as resultsets by using the T-SQL [`PRINT`][1] statement, but I'm not sure how those would get interpreted at the client side. Or even look at [`RAISERROR`][2] or the [`THROW`][3] part of a `TRY...CATCH...THROW`, but those could be really awkward to handle in code. [1]: http://msdn.microsoft.com/en-gb/library/ms176047.aspx [2]: http://msdn.microsoft.com/en-gb/library/ms178592.aspx [3]: http://msdn.microsoft.com/en-gb/library/ee677615.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.