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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Values along with the tag names

Author  Topic 

smitha
Posting Yak Master

100 Posts

Posted - 2010-01-04 : 01:01:28
hi,

using the below code I am able to get the tag names of a table.

Select name
from sys columns
where (object_id = OBJECT_ID(TABLENAME))

Using this I am lisitng the tag names in a list box. now if I want the values along with the tag names, how to go about it?

Please help me.

Smitha

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-04 : 01:49:18
isn't that just a SELECT <COLUMN NAME> FROM <TABLE NAME>


SELECT *
FROM TABLENAME



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-04 : 01:55:25
<<
Using this I am lisitng the tag names in a list box. now if I want the values along with the tag names
>>

What do you mean by a vlaue?

Madhivanan

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

smitha
Posting Yak Master

100 Posts

Posted - 2010-01-04 : 03:00:00
I am using a Trends in an application and sql as database.
Now using the above code I am able to retrieve the tag names from the database and put it in the list box in the application.

Now in the application, if I choose any tag name from the list box, for that tag name it has to show the values in the trend.

Smitha
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-04 : 03:36:49
then you might need to pass selected tag name as a parameter to a dynamic query as follows

SET @SQL='SELECT ' + @YourSelectedTag + ' FROM YourTable'
EXEC(@Sql)
Go to Top of Page

smitha
Posting Yak Master

100 Posts

Posted - 2010-01-04 : 06:23:02
Sorry, I couldn't get anything

quote:
Originally posted by visakh16

then you might need to pass selected tag name as a parameter to a dynamic query as follows

SET @SQL='SELECT ' + @YourSelectedTag + ' FROM YourTable'
EXEC(@Sql)



Smitha
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-04 : 07:23:16
quote:
Originally posted by smitha

Sorry, I couldn't get anything

quote:
Originally posted by visakh16

then you might need to pass selected tag name as a parameter to a dynamic query as follows

SET @SQL='SELECT ' + @YourSelectedTag + ' FROM YourTable'
EXEC(@Sql)



Smitha


Read this
www.sommarksog.se/dynamic_sql.html

Madhivanan

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

- Advertisement -