I keep getting the error:Server: Msg 156, Level 15, State 1, Line 26
Incorrect syntax near the keyword 'From'.
When I try to run the following code.
Any help in solving this is greatly appreciated.
I assume the error is referring to the last line where the FROM exist.
Declare @InPutDate as VarChar(255)
SET @InPutDate = '_'+ CAST(Datepart(month,GetDate()) as VarChar(2)) + '_W'
+ CAST(Datepart(Month,GetDate())as VarChar(2)) + CAST(Datepart(Day,GetDate()) as Varchar(2))+
'_' + CAST(Right(Datepart(Year,Getdate()),2)as VarChar(2))+ '_Test'
Declare @OutPutDate as VarChar(255)
SET @OutPutDate = '_'+ CAST(Datepart(month,GetDate()) as VarChar(2)) + '_W'
+ CAST(Datepart(Month,GetDate())as VarChar(2)) + CAST(Datepart(Day,GetDate()) as Varchar(2))+
'_' + CAST(Right(Datepart(Year,Getdate()),2)as VarChar(2))+ '_Test'
---Source Data tables Distribution Names
Declare @DistNamesSrcTable as VarChar(255)
Set @DistNamesSrcTable = 'Distribution_Names'+ @InPutDate
-----Output Table
Declare @AgentTble as VarChar (255)
Set @AgentTble = 'Distribution_Names'+ @OutPutDate
Declare @StrSQL as VarChar(5000)
--Here @AgentTble = Distribution_Names
--Declare @StrSQL as VarChar(5000)
--Set @StrSql = N'Select distinct number as agent_code INTO '+ @AgentTble + ' From ' + @AgentSrcTable +
--' Create index ix_1 on '+ @AgentTble + '(Company_id,contract,account)'
Set @StrSql = N'Delete * + ' From '+ @DistNamesSrcTable'
+ 'number = '8' and code ='400''
Incorrect syntax near the keyword 'From'.
When I try to run the following code.
Any help in solving this is greatly appreciated.
I assume the error is referring to the last line where the FROM exist.
Declare @InPutDate as VarChar(255)
SET @InPutDate = '_'+ CAST(Datepart(month,GetDate()) as VarChar(2)) + '_W'
+ CAST(Datepart(Month,GetDate())as VarChar(2)) + CAST(Datepart(Day,GetDate()) as Varchar(2))+
'_' + CAST(Right(Datepart(Year,Getdate()),2)as VarChar(2))+ '_Test'
Declare @OutPutDate as VarChar(255)
SET @OutPutDate = '_'+ CAST(Datepart(month,GetDate()) as VarChar(2)) + '_W'
+ CAST(Datepart(Month,GetDate())as VarChar(2)) + CAST(Datepart(Day,GetDate()) as Varchar(2))+
'_' + CAST(Right(Datepart(Year,Getdate()),2)as VarChar(2))+ '_Test'
---Source Data tables Distribution Names
Declare @DistNamesSrcTable as VarChar(255)
Set @DistNamesSrcTable = 'Distribution_Names'+ @InPutDate
-----Output Table
Declare @AgentTble as VarChar (255)
Set @AgentTble = 'Distribution_Names'+ @OutPutDate
Declare @StrSQL as VarChar(5000)
--Here @AgentTble = Distribution_Names
--Declare @StrSQL as VarChar(5000)
--Set @StrSql = N'Select distinct number as agent_code INTO '+ @AgentTble + ' From ' + @AgentSrcTable +
--' Create index ix_1 on '+ @AgentTble + '(Company_id,contract,account)'
Set @StrSql = N'Delete * + ' From '+ @DistNamesSrcTable'
+ 'number = '8' and code ='400''