"I have a procedure like the following, but it doesn't work: . solution that doesn't work not included because we already have the solution below . (please focus on Question 1 and 2 above) I want to have the field as variable to pass it through a different field. Which part of the is wrong?"
use northwind go Create Procedure GetFieldPath @FieldName varchar(10), @ReturnField varchar(10) As Declare @lcSQL varchar(300) Set @lcSQL ='Select @MyReturnField = ' + @FieldName +' From Customers' Exec sp_executesql @lcSQL, N'@MyReturnField varchar(10) output', @MyReturnField = @ReturnField output Select @ReturnField
|Do aggregate functions work differently when assigned to a variable?||15||33|
|How to use Full Text CONTAINS with Case in SQL||6||20|
|T-SQL - select ***test1*** from tbl_2 where [message] LIKE '%'+CAST((@test1) AS VARCHAR)+'%'||9||21|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
19 Experts available now in Live!