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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Passing table as parameter in sqlserver 2005

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2011-02-08 : 23:25:55
Hi friends,

Currently i am using 4 tables for logging purposes. for insertion in to that table am using 4 diff procedures by straight away quering the table name and insert query inside the procedure. is it possible to make it in generic way? by passing the table name as an parameter to procedure?.

thanks
subha.

Sachin.Nand

2937 Posts

Posted - 2011-02-09 : 00:21:31
Yes by using dynamic SQL.

PBUH

Go to Top of Page

Coolganny
Starting Member

3 Posts

Posted - 2011-02-09 : 22:17:00
You can either use

a) dynamic sql or
b) if statements

to achieve the same in 1 Stored procedure

Ganesh Ravi
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-10 : 03:42:29
quote:
Originally posted by subhaoviya

Hi friends,

Currently i am using 4 tables for logging purposes. for insertion in to that table am using 4 diff procedures by straight away quering the table name and insert query inside the procedure. is it possible to make it in generic way? by passing the table name as an parameter to procedure?.

thanks
subha.


Passing table name is not a good method. Use four insert statements in a single procedure

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -