General information
Forum:
Microsoft SQL Server
Ken,
>declare @sql varchar(128), @myvar varchar(16)
>set @sql = 'declare @myvar varchar(16) select @myvar = somefield from sometable where wherecondition'
>execute (@sql)
Can you not use a stored procedure with parameters (including an output parameter) to access the data you require?
For example
create procedure someprocedure
field varchar(20), table varchar(50), wherecondition varchar(200), myvar varchar(16) OUTPUT
as
select @myvar = @field from @table where @wherecondition
This will return the field required into the myvar variable
Cheers
Steve Lea
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only