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.
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.