Generating db script with SubSonic /version command - subsonic

I am using SubSonic version 2.2 to generate a script of my database using the /version command. Recently, I needed to generate a script for a database which is set to French collation and running on a French OS. The script fails because there are several columns which are of datatype "float" which use a comma instead of a period. (2,3 instead of 2.3). When I try to execute the sql script to re-import the data this causes an error. (column mismatch as the db engine thinks I am trying to insert too many columns). Is there any way to get the /version command to support internationalization? Is this supported in version 3? Modifying the original data is not an option unfortunately.
Thanks in advance.

Probably for this issue your best bet is to use Visual Studio and right-click on your DB selecting "Publish To Provider" - this generates the scripts for you (data too).
Sort of stuck on this one and no - 3.0 doesn't address this.

Related

How do I create a file from a result set?

I'm using Oracle 11g
I'm trying to create a flat file (CSV or TXT) from a result set but am struggling on where to even start. It seems like I have to create a stored proc and use UTL_FILE. After doing some research, I have two questions:
Where does the file get created? According to this question I need to get access to the Oracle user directory, but where is that on a Windows and Linux environment? I have to test on Windows , and the script will eventually be on a Linux environment.
What would be the basic format of a SQL script to create the aforementioned file, and load data into it from a fairly basic SELECT query? I'm not seeing a UTL_FILE function to write the records to the file; do I have to iterate through the entire result set and use PUT or can I somehow just push the entire result to a file?
I think using "spool" can do the trick.
Check this out https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9518534700346581975
And more information is here http://www.dba-oracle.com/t_sqlplus_spool.htm
The file will get created in the directory where you launch sqlplus from.
If you're using SQL Developer you can create a view for your query. Right click view in schema browser and choose export and export as csv.
But personally I would go for spool as previous answer said. SQL Plus is most basic client so I don't believe you won't have it.

Use Visual Basic for applications to read data from an Excel Spreadsheet database

I would like to know if it's possible to read data from an Excel spreadsheet used as database with Visual Basic for application (The IDE included in Microsoft Excel). I know it's possible with Visual Basic Studio but I don't know if it's possible using the Visual Basic IDE integrated in microsoft Excel.
Basically what I want to do is to create and authentification system this way (The spreadsheet will haw 3 columns : ID, Login and Password).
I will not be surprised if you tell me that using an Excel file as a databse is not the best practice but it is imposed to me and I must do it this way.
Thanks in advance for your help.
You can use it as a database. You can either call it with MS Query or open your dataset (invisibly) for reading. MS Query has the downside of considering values invalid at times.

Run VisualStudio classes (unit tests) from Excel?

Might be a silly question, but: Is it possible? For example, click a button in Excel that runs a specific C# unit test in VS, preferably also sending some info from Excel, and possible getting back the result of the run.
I've been doing this a lot in HP QTP/UFT, for running test cases. Now I'm using Selenium in C#/VS, and was thinking maybe there was a way to "streamline" it here too.
I'm using VS 2013 Express, btw - if there are possibilities for this, I realize they might be limited or non-existant in the Express version.
There is no standardized feature in any edition of Visual Studio that does this. One could build a plugin for Excel that does this. The Visual Studio Test Runner is a simple executable and it can output a XML file with the test results or you can attach your own logger (/logger) from the command line.
VSTO allows you to write a plugin for Excel that can execute C# code. Running the test runner and parsing the results from C# code should be relatively straight forward.
To populate the list of available tests, you can use /ListTests.

Update database with visual studio database projects

Hy,
I'am trying to use Visual Studio 2012 database project to upgrade a database to a newer version but i'am having a weird problem.I select the source database then the target database and hit compare.Visual Studio generates the script with the differences and when i execute it fails because it tries to drop tables without first dropping the FK constraints that are on those tables.(normally it should first script all the constrains from a table,drop them,drop the table,after that create the new table and finally recreating the constraints)
Do you have any ideas why it tries to do directly drop table without dropping constraints first.
Am i missing some settings?
Sounds like a bug to me. Try posting the same question on the SSDT forum.
If you have access to a copy of SQL Compare, it might be worth trying the same comparison to see if this works better. If you're using a database project as a data source, you'll need to select "source control", then "scripts folder", and browse to the folder that contains the .sqlproj file. Here at Red Gate we're working on improving database project support in SQL Compare so we'd welcome any feedback or questions.
If the tables that are being dropped in your database are not in your schema definition and you have got the "DROP objects in target but not in project" option selected in the Deployment Options, then it will try to drop them.
Have you checked this is not the case?
Whenever i work with database generating code from data models, or scrips, i often get that problem, so i have an script just for deleting those keys, sometimes i have to drop my database manually rather than executing the query, because most of the times it does but not completely, so i first dro the database, generate the script and run the script just for erasing the keys

Update target button is disabled after schema comparison

I have created database project using VS 2012. Once the schema comparison is done, the update target button should be enabled to sync with target.
But it's not getting enabled. Any help plz.
I'm using VS 2012 with sp 3, SQL Server 2012,
Check the Error List if you have any error, I had a non recognized word in VS (but it did in SQL Server), I commented it out, re-compared and it was enabled successfully.
See if you have a "warning" message stating "Cannot generate deployment plan due to an internal error". If so, the Update and Generate Script buttons will be disabled.
Close Visual Studio, navigate to the folder containing the Database project and remove all (*.dbmdl) files. Then restart Visual Studio, re-run the compare schema at which point the Update button should be enabled.
Workaround:
In my case. Fixing Error was not priority task. Also i was not able to find any Error in Error List.
Its just you dont have to use your "Visual Studio Database Project" in source or target. Instead of using project, create a temp DataBase using script already with you.
Select this (or these) temp database(s) in source and (or) other in target.
Button must be Enabled.
For me getting difference was far more important than fixing the issue. Hope it helps you. With some more improvisation.
It seems your database project has sqlcmd variables without default values.
See:
http://www.andrewburrow.net/vs2012-schema-compare-buttons-disabled/
Hope this helps.
I couldn't see any errors in Error List, but I could see the errors in the Output tab
the everytime you open the "options" on "schema comparison" you must click on "compare" button again to activate the "update" button. However if it doesn't work at the first time, just close and reopen the Schema comparison file again.
For me, there were no errors visible in the Error List. This was because I had the "Show Issues Generated" drop down was set to "Build Only"; changing it to "Build + IntelliSense" allowed me to see the SQL errors that needed to be fixed to enable the Generate Script and Update buttons.
In SSDT I had the case where the update button was enabled but the generate script was not enabled. This was because my destination schema was my local solution (the *.sqlproj vs project).
It took a few minutes to dawn on me that the destination needed to be a real database to correctly generate the script.
And after all, when you have the available Update Target button and the disabled Generate Script button.
See if your source is a database and your target is your SSDT project.
If so then click "Switch source and target" button.
The Generate Script button will become available.
I.e. a SSDT project must be the source and a database must be the target in the Schema Compare window.
Workaround 2:
In my case, the Update button was greyed out because of there were errors warnings about a view that I created and added to the project earlier.
The problem was that the view was scripted to use full database qualified object naming. E.g. [databasename].[schemaname].[objectname], which works fine in SSMS, but causes a problem when it is checked in a DB Project.
If you use three part naming for referring an object in same DB project results in a error/warning in Visual Studio.
By changing the code to [schemaname].[objectname] in the definicion of the view removed the error warnings and enable the Update option. Happy days!
Credits:
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/3577074-allow-three-part-naming-for-referring-a-db-object
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/17396128-keep-update-and-generate-update-script-buttons
Typically the update button is grayed out when the database objects are available in the separate sql files physically inside the database project but are not included in the database project itself. I simply added those sql scripts into the project and the update button got enabled after comparing the schema.
In my case, the Update button was disabled because there was a scalar function that was modified and that function was used in a computed column definition.
My solution was to:
Manually drop the computed column(s) in the database
ALTER TABLE <your table> DROP COLUMN <your computed column>
Re-run the schema compare
The Update button was enabled, and the update completed successfully

Resources