Column Name with Dynamic SQL
I use DynamicStagingArea for retrieval of a dynamic table.
I there any possibility to get the column names for the
...Dynamic column names in T-SQL?
Does anyone know of a clever hack that can be used to generate column names
on the fly, either from local variables or values in a temp table?
Robert Gumpertz wrote:
> Does anyone know of a clever hack that can be used to generate column names
> on the fly, either from local variables or values in a temp table?
For what purpose? I'm not following where you're going with this?
(maybe I need some caffeine?)
Mark A. Parsons
Iron Horse, Inc.
This is a reporting application where the user can submit a random list of
states; the result is a count by categ...Variable table name in dynamic SQL
Using Dynamic SQL (format 4) is it possible to make a table name
I get a SQL error: error near 'site' and SQLDBCode 102 when I try this:
String SqlStmt = "SELECT count(*) FROM ? "
PREPARE SQLSA FROM :SqlStmt using tDest; // tDest is valid!
DESCRIBE SQLSA into SQLDA ;
DECLARE row_count DYNAMIC CURSOR FOR SQLSA ;
SetDynamicParm(SQLDA, 1, "site")
OPEN DYNAMIC row_count USING DESCRIPTOR SQLDA;
The OPEN fails with SQLDBCode 102 and SQLErrText: SQL error near 'site'.
If I change the SQL to put in a fixed table name and add 'WHE...Dynamically setting the column name on a SQL query
Can anyone show me or tell if the following is possible.
I have a SQL query as shown below:
SQL = "SELECT revenue_forecast.oct AS 'revenue' ...........
What I need to do is dynamically set the column in this SQL query. So i need to be able to place a variable in the part after the revenue_forecast "." .
Can someone show me how to do this?
It depends on your data source, but most data sources do not allow you to parameterize column names. You have a couple of choices. One is to concatenate the name into the string as in...
SQL = "SELECT reven...table names and column names as local variables
Hi, can anyone tell me if there's some way to call a select statement in
wich the table name or column name is provided by a local variable? Like
declare @column_name varchar(30)
declare @table_name varchar(30)
select @column_name from @table_name
Thanx in advance
> Hi, can anyone tell me if there's some way to call a
> select statement in wich the table name or column name is
> provided by a local variable? Like this
> declare @column_name varchar(30)
> ...Dynamically name columns in dynamically created datagrid
I am using code that I found on the net to take a datatable, drop it into a datagrid, and then export the whole thing as an excel spreadsheet.
So far for the small numberes I have tried it works. Currently I have an application where the number of columns ranges between 40 and 70.
The problem that I have is I want the first row to have names which are meaningful to the user, but I don't want to rename my datatable columns, only the datagrid columns. Right now the Excel column names are the same as the datatable names. Those names are meaningful to me (the programmer) but meaningless to...SQL: Column names, can ONLY get "name" instead of "table.name"
When iterating through column names returned from a query, I need to get "table.name" rather than just "name"
Check it out:
If I have an SQL statement "SELECT table1.ID, table2.ID FROM table1, table2;"
And table1 has a column name 'ID'
and table2 has a column name 'ID' aswell,
and i run the query, the dataset will contain column names 'ID' and 'ID'
instead of 'table1.ID' and 'table2.ID'
It is extremely important that I can differenciate between the 2 fields, and know where each of them come from.
The same thing happen...How to use a full column name (table name and column name) with a DataReader
Hi, I have a problem retrieving the data with a DataReader from a stored proc that performs a join of two table with the same column's names but different data.
Let me explain with an example:
I have two tables:
Table1: Id, Name
Table2: Id, Name, IdTable1
The sproc is something like this:
CREATE PROCEDURE [dbo].[SearchByName]
FROM dbo.Table1, dbo.Table2
WHERE Table1.Id = Table2.IdTable1
AND Table1.Name LIKE '%' + @Name + '%'
And my c# code is something like this:
Database db = Databas...SQL query returns 'No column name' as a column heading
hi,I'm trying to execute this query in SQL Server 2005 Express Edition, the problem is in the column heading of the result for the majorName fieldSELECT studentID,fname,mname,lname,familyName,gpa ,(SELECT majorName AS major FROM major WHERE majorID=(SELECT majorID FROM studentmajorWHERE studentID='0000000'))FROM student WHERE studentID='0000000'; Why the result of this query returns 'No column name' as a label for the majorName field? I use the AS clause to allows the column to be named, the column heading of the result table still 'No column name&...Dynamic column name?
I am having one doubt which is mentioned below.
My doubt is i want to store a column name in the instance
By using the instance variable i want to check the
validation in itemchanged event.Is it Possible.....?
In the itemchanged event i want check the column like this.
This.Object.is_name[row] //where is_name contains some
You could use the older Describe method. Dot notation requires a
On 22 May 2004 08:25:55 -0700, Kalyan wrote:
>I am having one doubt which is mentioned below.
>My doubt is...Dynamic column names
How to add column names for a data window object at run time ?
( The datawindow object has already been created)
If you mean, assigning new names to existing columns at runtime, I don't
believe you can do that. If you mean creating a new one, here's a snippet
from the DWSyntax utility:
<DW Control Name>.Modify(&
"create column( id=<an integer> tabsequence=<an integer> accelerator='<a
single letter>' moveable=<0 - False, 1 - True> resizeable=<0 - False, 1 -
True> pointer='<Arrow!, Cross!, HourGlass!, IBeam!, Ico...how to variable column names
Can anyone tell how to specify a column name in an update query which is
stored in a local variable.
What I want to do is:
set @RatingColumn = 200
In the above query @RatingColumn is a local variable which stores the
column determined on the fly from a result from a cursor.
Thanks in advance.
You can use the existing EXECUTE IMMEDIATE functionality:
declare @cmdstring varchar(255)
select @cmdstring = "update #MyTable set "+@RatingColumn+" = 200"
> Can anyone tell how to sp...column name through a variable?
Is there a way to pass the name of a column through a variable?
For example, in ISQL I want to extract the column LastName from the table
CREATE VARIABLE @ColName CHAR(30);
SELECT @ColName FROM People;
In this example I obtain:
Which is not exactly what I hoped for :)
Thank you in advance.
You could use EXECUTE IMMEDIATE for a singleton select but not a
multi-row select until version 9 comes out (soon :)
On Thu, 24 Jul 2003 15:17:33 +0200, "Robin" <.@iol.it> wrote:...Can i use variable name as field name in power builder sql statement ?
Can i use variable name as field name in power builder sql statement ?like
if m_field_name is a variable with value of a fieldname of a table named
testtable how i can update the table
update "testtable" set m_field_name = 10 ;
is giving error
Lookup "Dynamic SQL Format 2" in the online help
Get Real Systems Ltd
Holtby Manor, Stamford Bridge Road, York, YO19 5LL
Tel 01904 481999 Fax 01904 481666
Visit us at www.getrealsystems.com
Specialists in e-Procurement and supply chain technology
<MNAIR> wrote in mess...