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 |
|
Mckay
Starting Member
8 Posts |
Posted - 2005-10-12 : 05:02:59
|
| hii want to make Stored Procedure like this:create proc sp_SelectTable @TableNm varchar(12) as select * from @TableNmany solution?thanks |
|
|
mriverol
Starting Member
10 Posts |
Posted - 2005-10-12 : 05:11:06
|
| Hi, you will need to use dynamic sqlexec ('select * from ' + @TableNm) |
 |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2005-10-12 : 16:26:53
|
| Wow! Why in the world would you want such an extremely generic routine? Performance and security on something like that in production would be brutal. And just for your own use, I'd think typing SELECT * FROM myTable is simpler and faster than typeing sp_SelectTable 'myTable'. Not to mention then adding filtering, etc. as you're doing your ad-hoc queries.OK, I'm starting to rant here, but I've seen entirely too many questions here trying to make a one-size-fits-all generic stored procedure for X. Bah!Oh, and by the way, ditch the tendency to prefix your stored procedures with sp_. That will hurt performance too because SQL Server will automatically try to locate it in Master before looking in your chosen database. It's just bad form.OK... Breathe... Sorry McKay, didn't mean to clobber you over the head there. Maybe you oversimplified your question and you're not really doing anything that drastic in real life. Welcome to SQLTeam. There are others here who are much more kind. I'll be moving along now...---------------------------EmeraldCityDomains.com |
 |
|
|
|
|
|