Groups | Blog | Home
all groups > sql server programming > april 2004 >

sql server programming : Field Value


Amol Kasbekar
4/23/2004 4:14:08 PM
Check sp_executesql from SQL BOL.

[quoted text, click to view]

Eugênio Spolti
4/23/2004 4:40:17 PM
Use dynamic Sql:


declare @NameField as char(20),
@Sql as char(200) ,
@Table as char(100)

set @NameField = 'Test'

set @Sql = ' select ' + @NameField + ' from ' + @Table

exec (@Sql)


"Thierry Marneffe" <Thierry.Marneffe@skynet.be> escreveu na mensagem
news:40896979$0$11084$a0ced6e1@news.skynet.be...
[quoted text, click to view]

Thierry Marneffe
4/23/2004 9:10:07 PM
Hello

Same type of question:

How can I get the value of a field having the field Name in a variable ?

Thanks for your help

Thierry


Thierry Marneffe
4/23/2004 10:00:18 PM

Hello Eugênio

Ok for your solution but ... I would like to use the value returned by the
select ...

In the tests I've done , if I do something like this:

set @Sql = '@MyData = select ' + @NameField + ' from ' + @Table

The variable @MyData is not available for the rest of the stored procedure
....

Any idea how to retrieve it ?

Thanks for your help
Thierry


[quoted text, click to view]

AddThis Social Bookmark Button