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 |
|
mccolld
Starting Member
1 Post |
Posted - 2004-09-27 : 10:59:45
|
| I'm trying to build a system with several different tables comprising the same structure (but they hold data that we'd like to keep separate).I'd like to use one SP and pass in the table name as a parameter but I can't see anything in Transact-SQL that will let you do this. I can construct a dynamic SQL statement inside the SP but this looks like a real pain when you're dealing with binary and image data.I can get a solution where I create stored procedures automatically in my create table script containing the table name but if possible I'd like to avoid that and find out if using just one is possible.Any ideas, or any ideas on dynamic SQL when dealing with image/binary data?e.g. CREATE PROCEDURE [dbo].[GetItem] (@ID uniqueidentifier) ASSELECT * FROM %TABLE% WHERE TableID=@ID%TABLE% would be replaced by the value in @tablename if this was to be passed in as a varchar |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-27 : 11:32:48
|
i don't think it's possible to do what you want like that.it's not a bas idea to have a sproc for every table. because they are precompiled they'll be fast.Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|