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 2000 Forums
 SQL Server Development (2000)
 Iterating by columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-25 : 07:55:44
santosh writes "In a sql trigger,
I have a statement ...
select * from inserted
assuming that i don't know the column names,
how to iterate through each column of row
like...
foreach column of inserted row,
get column name
THANKS."

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-10-25 : 08:08:18
how do you don't know the column names??
you have to.
there is no way to iterate through column names....
you can get all of the column names from information_schema.columns view though.

select column_name from information_schema.columns where table_name = 'yourTableName'

Go with the flow & have fun! Else fight the flow
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2005-10-25 : 10:01:57
The trigger is specific to a table. How can you not know the column names of the table? And why do you think you need to iterate through the column names anyway? I smell a conceptual issue here...why don't you tell us why you think you need to do this?
Go to Top of Page
   

- Advertisement -