Dear Sharchar
in this example, i insert 5 fields, and select 5 fields for insert.
['+RTRIM(left(convert(char,@tempdate,120),7))+'-Qty'+'] that will come out [2014-01-Qty], that is used as a column name.
The problem is related to how can I pass the value for selection.
(T00.DocDate >= convert(datetime,'+@tempdate+',5)) AND (T00.DocDate <= dateadd(day,-1,(dateadd(month, 1,convert(datetime,'+@tempdate+',5)))))
if I hardcode the date, it doesn't have any problem.
Regards
Edmund