all groups > sql server programming > may 2004 >
You're in the

sql server programming

group:

running a SP on a table (of abitrary name)


Re: running a SP on a table (of abitrary name) Aaron [SQL Server MVP]
5/31/2004 4:50:24 PM
sql server programming:
Do you mean take @tablename as parameter?

If the number of tables is small and well-defined:

IF @table_name = 'foo'
SELECT * FROM foo
IF @table_name = 'bar'
SELECT * FROM bar

If the number of tables is large or unknown:

http://www.sommarskog.se/dynamic_sql.html

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
(Reverse e-mail to reply.)




[quoted text, click to view]

Re: running a SP on a table (of abitrary name) Joe Celko
5/31/2004 6:48:07 PM
[quoted text, click to view]

No, you could learn basic software engineering and write properly
structured modules that have high cohesion instead.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
running a SP on a table (of abitrary name) toylet
5/31/2004 11:52:19 PM
Could I apply a stored procedure on a table of specific strucutre?

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.26
Re: running a SP on a table (of abitrary name) toylet
6/1/2004 7:59:19 AM
[quoted text, click to view]

so there is no other alternative but to use dynamic sql.... thanks.

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.26
Re: running a SP on a table (of abitrary name) Aaron [SQL Server MVP]
6/1/2004 9:32:40 AM
You don't need a "full-blown programming language" to write and design
sensibly.

--
http://www.aspfaq.com/
(Reverse address to reply.)




[quoted text, click to view]

Re: running a SP on a table (of abitrary name) toylet
6/1/2004 9:16:04 PM
But SQL Server's stored procedures after all is not a full-blown
programming language.

[quoted text, click to view]

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.26
AddThis Social Bookmark Button