I need the contents of Sample.dbo.sample_fields in order to know the second table definition. Can you simply script out the resulting table definitions for the project_id in question?
This query in dbo.CreateTargetTable looks like it cannot allow for a Unicode column to be created:
DECLARE Column_Cursor CURSOR
FOR
SELECT source_name,
coltype = CASE WHEN source_type = 1 THEN 'varchar(' + CAST(field_varSize AS VARCHAR(4)) + ')'
WHEN source_type = 2 THEN 'int'
WHEN source_type = 3 THEN 'datetime'
/* Code 4 converts Float to Varchar to get around Excel opendatasource */
WHEN source_type = 4 THEN 'varchar(' + CAST(field_varSize AS VARCHAR(4)) + ')'
END
FROM sample_fields
WHERE ID_Project = @ProjectID
AND source_name IS NOT NULL
ORDER BY source_sequence
I am assuming that either source_type 1 or 4 should generate an NVARCHAR column? If the second table is ANSI then you will lose the Unicode characters on INSERT and that is likely where the ? marks are coming from.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato