Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long SQL code in variable expression : Objecname column size #31

Open
tgauchet opened this issue Jan 3, 2019 · 1 comment
Open

Long SQL code in variable expression : Objecname column size #31

tgauchet opened this issue Jan 3, 2019 · 1 comment

Comments

@tgauchet
Copy link

tgauchet commented Jan 3, 2019

Hi Keith,
In an SSIS package we have long queries as expression in string value.. More than 1000 chars, and even more than 4000. those values are stored in Objectname column, defined as NVARCHAR(1000)
This lead to following issue:
"Committing analysis information to database...Unexpected error occurred: The given value of type String from the data source cannot be converted to type nvarchar of the specified target column."
We have change the column definition in Repository.cs
sqlCommand.CommandText = "IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Objects]') AND type in (N'U'))\r\n" + "BEGIN\r\n" + "CREATE TABLE [dbo].[Objects](\r\n" + " [RunKey] [int] NOT NULL,\r\n" + " [ObjectKey] [int] NOT NULL,\r\n" + " [ObjectName] [nvarchar](MAX) NULL,\r\n" +
What do you think about it?

@keif888
Copy link
Owner

keif888 commented Jan 9, 2019

It shouldn't be creating an ObjectName field with the expression's string value. That should be stored into the ObjectDesc field.

Can you please upload an example SSIS package that demonstrates your issue, so I can definitely fix it.
Make the SSIS package as simple as possible.

FYI:
The correct code to address this within Repository.cs should be as follows, and is checked into source now:

if (dbVersion == 9)
            {
                using (SqlCommand sqlCommand = repositoryConnection.CreateCommand())
                {
                    dbVersion = 10;
                    sqlCommand.CommandText = String.Format("INSERT INTO dbo.Version\r\n" +
                                            "(VersionID, InstallDate)\r\n" +
                                            "VALUES\r\n" +
                                            "({0}, GETDATE())", dbVersion);
                    sqlCommand.ExecuteNonQuery();

                    sqlCommand.CommandText = "ALTER TABLE [dbo].[Objects] ALTER COLUMN [ObjectDesc] NVARCHAR(MAX)";
                    sqlCommand.ExecuteNonQuery();
                }

            }

keif888 added a commit that referenced this issue Apr 5, 2022
…handle long queries etc. (Potential fix for Issue #31)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants