How do I pass columns/table names as parameters?

A

ajax.sam

hi all, i got 2 questions! i want to do these:

1. select @col1 from some_table where <some_conditions>; I can pass
parameters by using Parameters.Add for <some_conditions> but not for
the @col1. How do i do that? How do i pass column names as parameters?

2. select * from @table; How can i pass a table name as a parameter?

Thanks,
 
C

Ciaran O''Donnell

You can generate the full statement in C# and run it against the database
server, or generate the sql in the sp and all spexecute_sql and pass the sql
as an NVARCHAR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top