Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15694

Problem with string concatenation

$
0
0
declare @Topicid dtid
Declare @LevelID varchar(10)

select @Topicid = 'L10000'
select @LevelID= substring(@Topicid,1,2)  -- output - L1

select QID,Marks,Question from QBObjective	
where @LevelID+'SubjectID' = @TopicID -- FAIL

--L1SubjectID is my column name

//-- not giving any results, actually data is in table with specified id

print @LevelID+'SubjectID'  // output is L1SubjectID

-------actual syntax

select QID,Marks,Question from QBObjective	
where L1SubjectID = @TopicID -- Success

Please suggest me

Viewing all articles
Browse latest Browse all 15694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>