I have the following dynamic statement:
The actual statement looks like this:
When I execute it manually the record gets inserted, but when I use EXEC @sSQL I get the following error:
"INSERT INTO tmTaskTimeDetailsNonVoiceNet (sCalldate, sAgentid, sProject, sLogIn, sLogOut, sCallTime, dCallSec) VALUES ('20050714', '4358', 'jhtc0z', '10:00:00', '11:30:00', '01:30:00', 5400)' is not a valid identifier."
What does this error mean? What am I doing wrong??
Thanks,
Ninel
Code:
SET @sSQL = 'INSERT INTO ' + @Table + ' (sCalldate, sAgentid, sProject, sLogIn, sLogOut, sCallTime, dCallSec) ' + ' VALUES ( ''' + @sCalldate + ''', ''' + @cursorAgentId + ''', ''' + rtrim(ltrim(@sProject)) + 'z' + ''', ''' + @sStartTime + ''', ''' + @sEndTime + ''', ''' + convert(char(8), convert(datetime, @sEndTime) - @sStartTime, 108) + ''', ' + Convert(varchar(10),( datediff(ss, 0, convert(char(8), convert(datetime, @sEndTime) - @sStartTime, 108))) ) + ')'
The actual statement looks like this:
Code:
INSERT INTO tmTaskTimeDetailsNonVoiceNet (sCalldate, sAgentid, sProject, sLogIn, sLogOut, sCallTime, dCallSec) VALUES ( '20050714', '4358', 'jhtc0z', '10:00:00', '11:30:00', '01:30:00', 5400)
When I execute it manually the record gets inserted, but when I use EXEC @sSQL I get the following error:
"INSERT INTO tmTaskTimeDetailsNonVoiceNet (sCalldate, sAgentid, sProject, sLogIn, sLogOut, sCallTime, dCallSec) VALUES ('20050714', '4358', 'jhtc0z', '10:00:00', '11:30:00', '01:30:00', 5400)' is not a valid identifier."
What does this error mean? What am I doing wrong??
Thanks,
Ninel