none
save filed value to variable?

    Question

  • hi,

    i can save a value of field in to a variable,its possible?

    my code is:

    declare @FormName nvarchar(30)
    set @FormName=

    select EntityTypeName
    from Entity_Metadata
    where EntityTypeCode=538

    and i can use this variable in select command,

    select * from @formname

    Sunday, September 15, 2013 7:53 AM

Answers

  • Do you want to assign the value to the variable ..?

    try below

    declare @FormName nvarchar(30)
    set @FormName=(
    
    select EntityTypeName
    from Entity_Metadata
    where EntityTypeCode=538)
    
    ----
    
    select @formname  ---this just returns the assigned value
    
    select @formname ,* from <sometable>

    if the sub query returns more than one value then it will throw error.


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    Sunday, September 15, 2013 8:27 AM

All replies