Spaces in the connection string value of an SSIS CommandFile variable value - ssis

I am pretty new to SSIS (my first real project) and I have built a package that successfully performs some insert operations on a database. I want to deploy it to multiple environments, so I have created a connection manager whose connection string will be passed in from the command line which will in turn be defined in a command file.
The command that I run from the command line is ...
DTExec /F InitialDatabseImport.dtsx /CommandFile InitialCommandFile.config.txt
In the command file (InitialCommandFile.config.txt) I have the following variable assignment ...
/SET \Package.Variables[User::DBConnectionString].Properties[Value];"\"Data Source=(localdb)\ProjectsV12;Initial Catalog=DatabaseName;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;"\"
Running this I get the following error ...
Option "Source=(localdb)\ProjectsV12;Initial" is not valid.
It seems that is delimiting the connection string on spaces rather than semicolons.
I have tried a number of configurations with quotes. Here I changed the quotes in front of "Data" to something that seemed to make more sense ...
/SET \Package.Variables[User::DBConnectionString].Properties[Value];\""Data Source=(localdb)\ProjectsV12;Initial Catalog=MarketingPrefsDB;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;"\"
which returned the error ...
The argument "\Package.Variables[User::DBConnectionString].Properties[Value];\"Data" has mismatched quotes.
And this one, I wrapped the entire assignment in quotes ...
/SET "\Package.Variables[User::DBConnectionString].Properties[Value];\"Data Source=(localdb)\ProjectsV12;Initial Catalog=MarketingPrefsDB;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;\"";
which returned the error ...
Argument ""\Package.Variables[User::DBConnectionString].Properties[Value];\"Data" for option "set" is not valid.
Has anyone else who has seen this problem been able to figure it out?
Thanks,
G
UPDATE - 2014/07/21
When I put the SET command directly in the command line I am getting a slightly different error ...
Command Line ...
C:\Project>DTExec /F QuaeroInitialImport.dtsx /SET \Package.Variables[User::DBConn
ectionString].Properties[Value];"Data Source=servername;Initial Catalog=DatabaseName;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;"
Error Message
Argument ""\Package.Variables[User::DBConnectionString].Properties[Value];\"Data Source=servername;Initial Catalog=DatabaseName;Integrated Security=SSPI;Connect Timeout=30;Auto Translate=False;" for option "set" is not valid.

I've met similar issue and just share my work-around in case others reach here thru google.
My case is:
Deploying the package on SQL Server 2014, and I use some package parameter in the package and met this issue. I've met this if I don't use package parameter on another server running SQL Server 2014 also (both server are running the same version of SQL Server 2014).
I fix this by replacing all spaces in the keywords of the connection space with an underscore (_). The connection work for me on my server like:
Data_Source=xxx.xxx.xxx.xxx,xxxx;Initial_Catalog=ABC_DEF;Provider=SQLNCLI11.1;Persist_Security Info=True;Auto_Translate=False;User_ID=userabc;
Please note even I have forgotten to replace some space in some keyword, it still works.
So I finally change it as below:
Data_Source=xxx.xxx.xxx.xxx,xxxx;Initial_Catalog=ABC_DEF;Provider=SQLNCLI11.1;Persist_Security_Info=True;Auto_Translate=False;User_ID=userabc;
So... it doesn't make me comfortable in this case as I am not sure actually if it is working on a correcting settings... you still have to verify it yourself.

Related

SSIS ODBC Simba - Error when access table list on ODBC Source \ Destination

I'm using Simba ODBC to create a connection with Google Big Query and using SSIS (Visual Studio 2019) to read and write information on Big Query. The connection works fine and when I use the ODBC Source with the query option, I'm able to get data from Big Query and used it inside SSIS. But when I use the list of tables, I get an error as below:
Exception of HRESULT: 0xC0014020
Error in Data Flow Task[ODBC Source [100]]: SQLSTATE: 42000, Message: [Simba][BigQuery] (70) Invalid query: Invalid dataset ID ""TEST"". Dataset IDs must be alphanumeric (plus underscores and dashes) and must be at most 1024 characters long.
I believe that this happens because the list of tables appear between ("), instead of (`).
Print of table list
The same happens when I use the ODBC Destination. Is there a way to change the format in which the table list appears ?
Obs.: On the Visual Studio 2015 this table list comes with (`) and I can connect with big query just fine.
I can see that the tool is sending "TEST" as the dataset, however, depending on if Visual Studio is using StandardSQL or LegacySQL, the dataset should be specified as:
# LegacySQL
FROM [myproject:TEST.TABLE_TEST]
# StandardSQL
FROM `myproject:TEST.TABLE_TEST`
I was wondering if Visual Studio accepts a custom query or can be parameterized to remove the quotes. If this doesn't help, could you please share the query that cause the error? I understand that there is a query option (I'm not familiar with Visual Studio) and it is not clear for me the exact moment when the tool returns the error, screenshot without sensitive information would be appreciated.
UPDATE:
You can review the following checkpoints that could help to verify that the Simba driver is correctly set up and it is not the cause of the reported error:
Installation. Check that you are using the last version of the driver. The last version usually contains improvements on the driver.
ODBC Configuration. For example, the Step 13 of the link you will be able to see a drop-down list with the datasets available and select one as the default. If you don't have issues is this step, then the issue could be in the tool that uses the ODBC connection.
Language Dialect. In here you case change between StandardSQL or LegacySQL as needed, for example, you can force your tool to use LegacySQL and use the characters [ and ] that I explained above.
Connection String. If your tool allows to use a string with the connection, you might want to use it and explicitly indicating the default Dataset (among other driver options).

SSIS 2008 String Variable with Analysis Services XMLA Command

I'm having an issue whereby I'm attempting to build up an XMLA command within an SSIS 2008 variable so that I can create/process Analysis Services 2008 partitions dynamically. The issue I'm facing is the XMLA command contains double quotes and I have tried escaping with \ but even though the SSIS expression box shows me the command correctly formatted, the ssis string variable shows the backslash.
e.g SSIS expression I enter is:
"<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">"
SSIS expression is then evaluated correctly and shown as:
<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
but in the actual ssis variable (evaluated as an expression) the value is:
<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">
Note the backslashes are visible.
Can anyone help?
Thanks
We are currently doing this successfully by using quotes to escape the quotes. Here is an example from our working script task:
" xmlns=""http://schemas.microsoft.com/analysisservices/2003/engine""> "
what worked in my case is :
1) wrap the XMLA in a select as below (taking AdventureWorks for example and using variables as well):
"select
'<Create xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">
<ParentObject>
<DatabaseID>AdventureWorksDW2012Multidimensional-EE</DatabaseID>
<CubeID>Adventure Works</CubeID>
<MeasureGroupID>Fact Internet Sales 1</MeasureGroupID>
</ParentObject>
<ObjectDefinition>
<Partition xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ddl2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2\" xmlns:ddl2_2=\"http://schemas.microsoft.com/analysisservices/2003/engine/2/2\" xmlns:ddl100_100=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\" xmlns:ddl200=\"http://schemas.microsoft.com/analysisservices/2010/engine/200\" xmlns:ddl200_200=\"http://schemas.microsoft.com/analysisservices/2010/engine/200/200\">
<ID>Internet_Sales_"+#[User::year_recorded]+"</ID>
<Name>Internet_Sales_"+#[User::year_recorded]+"</Name>
<Source xsi:type=\"QueryBinding\">
<DataSourceID>Adventure Works DW</DataSourceID>
<QueryDefinition>SELECT [dbo].[FactInternetSales].[ProductKey],[dbo].[FactInternetSales].[OrderDateKey],[dbo].[FactInternetSales].[DueDateKey],[dbo].[FactInternetSales].[ShipDateKey], [dbo].[FactInternetSales].[CustomerKey], [dbo].[FactInternetSales].[PromotionKey],[dbo].[FactInternetSales].[CurrencyKey],[dbo].[FactInternetSales].[SalesTerritoryKey],[dbo].[FactInternetSales].[SalesOrderNumber],[dbo].[FactInternetSales].[SalesOrderLineNumber],[dbo].[FactInternetSales].[RevisionNumber],[dbo].[FactInternetSales].[OrderQuantity],[dbo].[FactInternetSales].[UnitPrice],[dbo].[FactInternetSales].[ExtendedAmount],[dbo].[FactInternetSales].[UnitPriceDiscountPct],[dbo].[FactInternetSales].[DiscountAmount],[dbo].[FactInternetSales].[ProductStandardCost],[dbo].[FactInternetSales].[TotalProductCost],[dbo].[FactInternetSales].[SalesAmount],[dbo].[FactInternetSales].[TaxAmt],[dbo].[FactInternetSales].[Freight],[dbo].[FactInternetSales].[CarrierTrackingNumber],[dbo].[FactInternetSales].[CustomerPONumber]
FROM [dbo].[FactInternetSales]
WHERE "+#[User::WHERE_clause]+"</QueryDefinition>
</Source>
<StorageMode>Molap</StorageMode>
<ProcessingMode>Regular</ProcessingMode>
<ProactiveCaching>
<SilenceInterval>-PT1S</SilenceInterval>
<Latency>-PT1S</Latency>
<SilenceOverrideInterval>-PT1S</SilenceOverrideInterval>
<ForceRebuildInterval>-PT1S</ForceRebuildInterval>
<AggregationStorage>MolapOnly</AggregationStorage>
<Source xsi:type=\"ProactiveCachingInheritedBinding\">
<NotificationTechnique>Server</NotificationTechnique>
</Source>
</ProactiveCaching>
<EstimatedRows>1013</EstimatedRows>
<AggregationDesignID>Internet Sales 1</AggregationDesignID>
</Partition>
</ObjectDefinition>
</Create>
'
as xmla"
and assign the above as string to a String variable .
2) drag in an execute SQl task and supply variable in 1) as 'SourceVariable' . Run this SQL task on a connection manager for normal transactional DB , say 'master' for instance .
3) save the 'Single Row' resultset from 2) in another String variable.
4)supply the variable from 3) to another Execute SQL task using the connection manager for SSAS cube .
hope this helps anyone landing on same ...

SSIS The expression for variable 'Variable' failed evaluation. There was an error in the expression

So here we have an error I keep getting in my SSIS package but I can't see what is wrong with the statement. I have even tried another sql statement from a project that works and it still raises the error.
The system is VS 2005 running 64 bit debugger, on XP machine. The project has amongst other things a script task then a sql task, the script task outputs the month value to a variable (Dts.Variables("monthName").Value = month), which I then use to create dynamic table name in SQL statement. I haven't got to the excel sheet bit yet as I am trying to get the sql task stage working.
So i have a variable at package level called SQLTableCreate, and in that I have the properties set to:
Evaluate as Expression = true
Expression = "Create Table "+ #[user::monthName]+"(Column1 DATETIME,Column2 NVARCHAR(255),Column3 NVARCHAR(255),Column4 NVARCHAR(255),Column5 NVARCHAR(255),Column6 NVARCHAR(255),Column7 NVARCHAR(255),Column8 NVARCHAR(255),Column9 NVARCHAR(255),Column10 NVARCHAR(255))"
And when I build the package I get:
Nonfatal errors occurred while saving the package:
Error at Package: The variable "user::monthName" was not found in the Variables collection. The variable might not exist in the correct scope.
Error at Package: Attempt to parse the expression ""Create Table "+ #[user::MonthName]+"(Column1 DATETIME,Column2 NVARCHAR(255),Column3 NVARCHAR(255),Column4 NVARCHAR(255),Column5 NVARCHAR(255),Column6 NVARCHAR(255),Column7 NVARCHAR(255),Column8 NVARCHAR(255),Column9 NVARCHAR(255),Column10 NVARCHAR(255))"
" failed and returned error code 0xC00470A6. The expression cannot be parsed. It might contain invalid elements or it might not be well-formed. There may also be an out-of-memory error.Error at Package: The expression for variable "SQLTableCreate" failed evaluation. There was an error in the expression.
There is also a default SQL statement for the variable SQLTableCreate, which uses the current excel connection manager table name. When I put my dynamic statement in the expression section of properties it fills the value and valuetype property of the SQLTableCreate variable with the message:
The expression for variable "SQLTableCreate" failed evaluation. There was an error in the expression.
It's exactly as the error says
The variable "user::monthName" was not found in the Variables collection
Things in SSIS are case sensitive and Variables are one of those things. Make your expression
"Create Table "+ #[User::monthName]+"(Column1 DATETIME,Column2 NVARCHAR(255),Column3 NVARCHAR(255),Column4 NVARCHAR(255),Column5 NVARCHAR(255),Column6 NVARCHAR(255),Column7 NVARCHAR(255),Column8 NVARCHAR(255),Column9 NVARCHAR(255),Column10 NVARCHAR(255))"
Also, I hope this table design is just a sample and not real. Lack of column names and strong data types is technical debt you don't need to incur at this stage.

How to undo sql USE?

What's the SQL command to undo:
USE db;
The syntax I see everywhere is:
USE [db] ;
implying that I can leave out the db part. Not so - this is a syntax error however (maybe just syntax errors in the SQL syntax syntax?).
edit
The programming problem this is causing is that I can't reset the environment in which subsequent commands run. I could reset my DB connection, but this seems efficient.
cmdX; // Works
vs.
cmdX;
cmdY; // May fail because command X upset some state.
cmdX should clean up after itself and put things back where it found them.
Analogously:
cd ./a
doX()
cd ../
doY() // Y expects to not be in a?
I don't think you can. The documentation doesn't say the parameter is optional. It says:
The database remains the default until the end of the session or another USE statement is issued:
So if you want to drop the default, end your session and start a new one without selecting a DB.
What programming problem is this causing for you?
The database argument is not optional.
mysql> use
ERROR:
USE must be followed by a database name
I'm not sure where you saw this command with square brackets around the argument. That is not shown at the documentation page: http://dev.mysql.com/doc/refman/5.6/en/use.html
Microsoft SQL Server uses square brackets around identifiers (as opposed to a style to indicate an optional argument), but the MS SQL documentation for USE also doesn't show it: http://msdn.microsoft.com/en-us/library/ms188366.aspx
What would it mean to "undo" a USE command? Would it be like cd - in bash, making the previous default database again the default? There is no such command in MySQL for this. It doesn't remember what was your previous default database. If you want to return, you just have to USE that database and name it explicitly.

Could not find server 'dbo' in sys.servers

I have a lot of services which query the database. All of them work fine but one service calling a stored procedure gives me following error:
Could not find server 'dbo' in
sys.servers. Verify that the correct
server name was specified. If
necessary, execute the stored
procedure sp_addlinkedserver to add
the server to sys.servers.
I have not idea why all the other stored procedures work fine and this one not...
By the way, I use SubSonic as data access layer.
Please run select name from sys.servers from the server which you mentioned as default server in configuration file.
Here in name column values should match with your server names used in the report query.
e.g serverXXX.databasename.schema.tablename
serverXXX should be there in the result of select name from sys.servers otherwise it gives error as got.
It sounds like there is an extra "." (or two) in the mapping - i.e. it is trying to find server.database.schema.object. Check your mapping for stray dots / dubious entries.
Also make sure that the server name matches what you think it is. If you rename the host that SQL Server is running on, you need to rename the SQL Server, too.
http://www.techrepublic.com/blog/datacenter/changing-the-name-of-your-sql-server/192
I had another issue with the same exception so I'll post here if someone stumble upon it:
Be careful if you specify the server name in synonyms. I had a different server name on my staging machine and production and it caused the same 'cannot find server'-error.
(Guess you shouldn't use synonyms that much anyway but it's useful in some migration scenarios)
In my case i was facing same issue with following ,
SqlCommand command = new SqlCommand("uspx_GetTemplate", connection);
but after adding square bracket to stored procedure name it get solved.
SqlCommand command = new SqlCommand("[uspx_GetTemplate]", connection);