473,657 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I pass columns/table names as parameters?

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

1. select @col1 from some_table where <some_condition s>; I can pass
parameters by using Parameters.Add for <some_condition sbut 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,

Sep 30 '08 #1
1 1720
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
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"aj******@gmail .com" wrote:
hi all, i got 2 questions! i want to do these:

1. select @col1 from some_table where <some_condition s>; I can pass
parameters by using Parameters.Add for <some_condition sbut 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,

Sep 30 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5287
by: Ray | last post by:
Group, Passing inline values to a udf is straightforward. However, how or is it possible to pass a column from the select of one table into a udf that returns a table variable in a join to the original table. The goal is to explode the number of rows in the result set out based on the result of the udf. Although the example I am providing here is simplified, we are trying to parse out multiple values out of a text column and using a...
2
1811
by: jlficken | last post by:
I am trying to create a stored procedure that accepts 3 parameters. Using these parameters I am joining on 2 tables and a UDF that accepts these 3 parameters to get movement information. When I try to pass these parameters in the function for each parameter I get and SQL0206 'Position # Column &1 not in specified table'. I am using DB2 on an AS/400 running V5R2 for the operating system. I will post a n example below. CREATE PROCEDURE...
8
1372
by: nick | last post by:
I have a function to update a database table with 40 columns. currently I created the function with 40 parameters which is very ugly, any best practice to handle this situation?
13
2481
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks). Currently this code write all columns to a single row which works but is not what the boss wants. If anyone has suggestions how you would do a report like this I very much would like to hear them as well. vb.net windows app. ...
5
13664
by: adi | last post by:
Hi all, Seems like a fundamental question to me but I dont have a definite answer for it, Gurus please enlighten me. I have a table 'Table1' whose structure changes dynamically based on some configuration values from another table. This table is being used by a program, It was initially used by this program which ran as a single task (executing at only a specific interval) but now the program has to be run mutiple times some coinciding...
13
2154
by: andrea | last post by:
Sorry for the stupid question, I know, but sometimes is necessary starts from the basic. I don't know how to pass the result of a method generated from a DAL class to a BL class returning the results as it is. I mean, for instance, something like this. namespace DAL {
0
1126
by: rn5a | last post by:
An ASP.NET app retrieves 3 columns named Product, Category & Price from a SQL Server 2005 DB table & displays them in a DataList. The headers of these 3 columns in the DataList are Product, Category & Price respectively. I want to give users the option to sort the items in the DataList. All the 3 columns can be sorted by clicking the headers which are LinkButtons. To do this, I want to invoke a sub-routine named SortDataList which...
5
2161
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can change depending how many columns are in a Table. I add a new column with this code: Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Try...
12
4625
by: ArunDhaJ | last post by:
Hi Friends, Is it possible to pass a table as a parameter to a funtion. whos function declaration would look some thing like this.... ALTER FUNCTION TempFunction (@TempTable TABLE, @nPId INT) my problem is: i have to access a temporary table created in an SP in a function
0
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8601
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.