July 25, 2017 at 1:03 pm
Hi,
i am trying to execute below command but output is not getting .In my table year is 2017.
can anyone help me
SET @TableName = 'dbo.my_latestyear_ + CAST(@Year AS Varchar(4))_new'
RETURN @TableName
OutPut Come like --->my_latestyear_2017_new
but output coming like dbo.my__latestyear + CAST(@Year AS Varchar(4))_new
please help me out.
July 25, 2017 at 1:07 pm
Sree Divya - Tuesday, July 25, 2017 1:03 PMHi,i am trying to execute below command but output is not getting .In my table year is 2017.
can anyone help meSET @TableName = 'dbo.my_latestyear_ + CAST(@Year AS Varchar(4))_new'
RETURN @TableNameOutPut Come like --->my_latestyear_2017_new
but output coming like dbo.my__latestyear + CAST(@Year AS Varchar(4))_new
please help me out.
You need to close the quotes before adding the year, instead of after.
July 25, 2017 at 1:08 pm
SET @TableName = 'dbo.my_latestyear_' + CAST(@Year AS Varchar(4)) + '_new'
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 25, 2017 at 1:27 pm
Sree Divya - Tuesday, July 25, 2017 1:03 PMHi,i am trying to execute below command but output is not getting .In my table year is 2017.
can anyone help meSET @TableName = 'dbo.my_latestyear_ + CAST(@Year AS Varchar(4))_new'
RETURN @TableNameOutPut Come like --->my_latestyear_2017_new
but output coming like dbo.my__latestyear + CAST(@Year AS Varchar(4))_new
please help me out.
DECLARE @tablename varchar(100)
,@Year varchar(4)
SET @Year='1994'
SET @TableName = 'dbo.my_latestyear_'+ CAST(@Year AS Varchar(4))+'_new'
print @TableName
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply