Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Is There any difference in Set @Var=ColmnName and Select @Var =Column from Table. I am using it in SSIs for Dynamic Packages

$
0
0
hey there, Kindly elaborate me the difference Between Set and Select clause while Providing value to a Variable or Even  a  Column.

    Declare @var nvarchar(Max)
    
    Set @var= (Select TestName+ cAst(TestId as nvarchar) from TblTest where TestID=1)
    
    Insert into TblTest(TestName)
    Values (@var)
    
    --------------------------------
    
    Declare @var nvarchar(Max)
    
    Select @var= (Select TestNAme + Cast(TestId as Nvarchar(MAx)) from TblTest Where TestID=1)
    
    Insert into TblTest(TestName)
    Values(@var)
    
    
    -------------------------------


Values and result I am getting is Same in Both.
But just wondering if there is any Difference. and if Any which Should I prefer.
And Which one uses less Resources.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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