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)
 variable query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-10 : 09:30:29
Andres writes "I need to make a query on a table over 10 fields. The field names are the same except by one character

select field1 from ....
select field2 from ....
.
.
.
.
select field10 from ....

i want to change this statements for somethin like

while(@V<10)
begin
select field+'@V' from .....
select @V=@V+1
end

is this possible.

any idea, thanks."
   

- Advertisement -