Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to create list from separate Sql
Message
 
To
05/02/2019 10:18:26
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2016
Miscellaneous
Thread ID:
01665900
Message ID:
01665928
Views:
40
>Hi Borislav
>
>I see where we're going with this, and now, that section looks like
>
>  declare @TheOutputValue nvarchar(30) = ''
>  set @ThisSQL =  '(Select @TheOutputValue = CAST(' +  @ThisField  + ' as nvarchar(30)) from ' 
>      + @FileName + ' where ' + @KeyFieldName + ' = ' + cast(@KeyFieldValue as Varchar) + ')'
>  exec sp_executesql @ThisSQL, N'@ThisValue  nvarchar(30) OUTPUT', @ThisValue = @ThisValue 
>
>
>It keeps telling me I need to declare the scalar variable "@TheOutputValue", so (obviously) there's still something I'm missing


Sorry, my mistake.
I used @TheOutputValue but after that I decided to switch the name and forgot to use it in the query:
...
 set @ThisSQL =  '(Select @ThisValue = CAST(' +  @ThisField  + ' as nvarchar(30)) from ' 
      + @FileName + ' where ' + @KeyFieldName + ' = ' + cast(@KeyFieldValue as Varchar) + ')'
...
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform