 |
|
 |
Has anyone tried to use this tool with SQL Server 2005 ? (I'll have a closer look at it myself as soon as i have the time).
We are looking for a way to store SCADA applications in SVN, so this would be quite handy for us. A few SCADA systems we use (like Siemens WinCC) are based on SQL Server these days, which makes the use of SVN hard since the whole database must be detached, checked in and re-attached with every change, and most of that data is useless anyway.
If anyone has experience with it, i would like to share idease with him/her.
regards,
Peter
|
|
|
|
 |
|
 |
Your program deletes all previous *.sql files in all directories (well deletes in the root and blanks in subfolders). This is assuming that everything in the project folder where you run this executeable is owned by the executable. I had created a version update file for migration (surely one of the reasons to have versioned control databases) and this got nuked before I committed it. Doah!
To cope with this I've hard coded a it so it won't delete from a folder called updates now on but it would be cool if you could have an exclusions folder in the config. Just looked and found out it has been nuking my livedata files, my test scripts too... lucky for version control!
Thanks though for creating it. It's been very useful otherwise!
|
|
|
|
 |
|
 |
I have a "varbinary(max)" data-type in a table def, and scriptdb4svn is generating the following on an exportdb:
[value] [varbinary] (-1) NULL ,
which is invalid sql
I can't just substitute an actual number in the column def, since anything over 8000 is rejected. SQL Server won't take an actual length > 8000, hence the "max" keyword. "varbinary(max)" means anything well into gigabyte range.
How can I have a varbinary and have scriptdb4svn handle it correctly?
|
|
|
|
 |
|
 |
It appears the SQL scripter from SQL Server 2000 doesn't support the varchar(MAX). I hacked together a fix several months ago. In the Program.cs near the bottom, I added the following lines.
// Trim trailing \n so output of different servers is the same
statement = statement.TrimEnd(new char[] {'\n', '\r'});
if (includeOwner && owner.Length > 0)
objectname = owner + "." + objectname;
string varbinary = "[varbinary] (-1)";
if (groupName == "Tables" && statement.Contains(varbinary))
statement = statement.Replace(varbinary, "[varbinary] (max)");
string varchar = "[varchar] (-1)";
if (groupName == "Tables" && statement.Contains(varchar))
statement = statement.Replace(varchar, "[varchar] (max)");
string filename = outputPath + "\\" + groupName + "\\" + objectname + ".sql";
|
|
|
|
 |
|
 |
I have a user-defined function that contains the following in a comment:
/*
SCRIPTING NOTE:
When generating a SQL script for the database, the script creates this function before some of the objects it depends on.
To avoid errrors, move the "CREATE FUNCTION dbo.GETUSERFUNCTIONDEPARTMENTS" before "CREATE VIEW dbo.View1".
*/
Your script detects the creation of a new view and starts scripting a view that contains an error. How would you update this code to ignore create statements that have been commented out? I believe you need to add something to the regular-expression, but I'm not a RegExpert. Any ideas?
|
|
|
|
 |
|
 |
I've found the utility does not like comments in triggers to appear before the "AS". If comments occur before "AS", the comment is included in the object's name.
|
|
|
|
 |
|
 |
Some old sql view's are not identified well and makes the code stop processing the database:
The issue is:
Normal view looks like this:
Create View view_name
AS
Select ...
View can also be declared this way:
Create View view_name(column_name1, column_name2, ...)
AS
Select ...
Some people prefer to enlist the result column layout in the view declaration section instead of writing the wanted (alias) name in the select statement at the appropriate column/line (example: Select table_name1.column_name1 As col_1)
Now the code is prepared for the simple version only, and breaks on the one which lists the columns
Since I am not really familiar with regex I cannot really make an appropriate regex for the views. (I do not have VS2005 either)
Could you make some modification to detect this declration type as well in the views?
Compile a new version or at least give me some hint what to change in the regex and then I will try to get VS2005 and compile it for myself.
Thanks a lot,
Andrew
|
|
|
|
 |
|
 |
I've adjust the Views RegEx to this (includes the WriteGroup method for reference:
WriteGroup("Views", "(?<Statement>CREATE VIEW (?<Owner>[^\\.\\s]*?\\.)?(?<Name>.*?)\\s+(?:AS|\\()\\s+.*?)\\s+GO\\s", scriptInput, outputPath, includeOwner);
|
|
|
|
 |
|
 |
?<Statement>CREATE VIEW (?<Owner>[^\\.\\s]*?\\.)?(?<Name>.*?)\\s+AS\\s+.*?)\\s+GO\\s
The RegEx for VIEWS above does not exclude statement permissions like these:
GRANT CREATE TABLE , CREATE VIEW , CREATE PROCEDURE , DUMP DATABASE , CREATE DEFAULT , DUMP TRANSACTION , CREATE RULE TO [SlydellB]
GO
I don't have any experience with RegEx. How to fix that?
Best Wishes,
Robin
|
|
|
|
 |
|
 |
It's useful for development tool, but I can't work with SQL Server 2005 I can't find scptxfr.exe. What should I do? Do you know other tools use IDE SQL Server with SVN?
Chhers,
Samnang
|
|
|
|
 |
|
 |
Hi,
After trying (I am new to C#) and searching the internet, I realized that this project has been implemented using Visual Studio 2005 and possibly with C# version later to 1.1.
That's why I was getting the errors. Changing this utility so that I can compile it with C# version 1.1, I need to change the code (no static class is allowed with versions prio to 2, Container classes are different, etc) which amount to re-writting the utility.
I was just wondering if you have a version of this utility that was implemented using Visual Studio (version prio to 2005 and C# 1.1)?
Regards,
/**********************
David nsengiyumva
3, Clarendon Road,
Rosebank, 7700
Cape Town
***********************/
|
|
|
|
 |
|
 |
See my comment on your previous post.
Cheers
|
|
|
|
 |
|
 |
Hi, The following line in the 'DataScripter' static class: List<string> sortColumns = new List<string>(); gives the following error: Invalid expression term 'string' Any idea what's causing this or how to fix this. Many thanks N.B: I am using Visual Studio .Net 2003 /********************** David nsengiyumva 3, Clarendon Road, Rosebank, 7700 Cape Town ***********************/
|
|
|
|
 |
|
 |
This is a C# 2.0 project, will only compile in Visual Studio 2005 and up.
If you want to convert the code to 1.1, convert the generic definitions to plain ArrayLists:
this code:
List sortColumns = new List();
becomes:
ArrayList sortColumns = new ArrayList();
There will probably be more issues along the way. If you say you are new to C#, I wouldn't recommend trying to convert the code. Good luck with it anyways!
|
|
|
|
 |
|
 |
Hi,
I've been trying to open the project file using Visual Studio .NET 2003 but I get an error message saying that ScriptDB4SVN.csproj' is not a valid project file and I have checked the file against my other project files and it looks different... Any idea how to fix this??? I tried creating a new project but I don't know the type of project to create... Any help will be appreciated.
Thanks
/**********************
David nsengiyumva
3, Clarendon Road,
Rosebank, 7700
Cape Town
***********************/
|
|
|
|
 |
|
 |
This is a C# 2.0 project, will only compile in Visual Studio 2005 and up.
|
|
|
|
 |
|
 |
This code worked like a champ. I can say we upgraded recently to 2005 and this still works on our database using Scptxfr.exe and .rll files from the sql 2000 server install disk.
I had to make 1 modification to the code to exclude some wierd characters we are using in the tablenames?
Just used an "objectname = objectname.Replace()", if anyone else needs to do the same.
Thanks
|
|
|
|
 |
|
 |
My database has a table named "User" in it. Unfortunately "User" is are MS SQL Server reserved keyword. I know, naughty me. Unfortunately, this breaks your code at line 55 of the DataScripter.cs file. The line reads:
command.CommandText = string.Format("SELECT * FROM {0} ORDER BY {1}", table, orderBy);
I fixed it by adding brackets around the table reference:
command.CommandText = string.Format("SELECT * FROM [{0}] ORDER BY {1}", table, orderBy);
Other than that, your app is working well. Thanks for the help.
--
Tod Birdsall, MCSD for .Net
software blog: http://www.tod1d.net
|
|
|
|
 |
|
 |
Go to www.red-gate.com and download a program called 'SQL Refactor'. This will allow you to rename those pesky objects with reserved keywords as the name... They offer a 30 day trial so there isn't anything to lose - you might even want to buy it.
I don't work for red-gate, I am a user and I absolutely love it so I thought I would share. hth
|
|
|
|
 |
|
 |
Instead of reverse engineering your database back into scripts and then putting those scripts in PVCS, you should create/checked out the scripts and then updated the database with them. Wow, I'm shocked if people use this process in production environments.
What you propose would be okay for a one time operation if this was never done for some reason (for example you took over from a newly fired consultant).
|
|
|
|
 |
|
 |
Thanks for your comments.
Unlike PVCS, SVN doesn't use a locking mechanism for files managed. This is one of the great benefits of SVN. In the scenario of database versioning, this literally means you and one or more of your collegues can make changes to the same table at the same time, check in those changes and all have these changes merged back into their local databases seamlessly.
Your suggested solution would work great in a single database server development environment, with all developers working on that one database all at the same time. However, this tool provides a way to have developers independently work at local versions of their databases, and only check in/merge changes back into mainstream development once their changes have been successfully implemented. Just like they would do with their source code files.
Also, this tool is not targeted for use in production environments, it is a development tool for use in development environments.
|
|
|
|
 |
|
 |
Foreign keys can go unnamed, so the regular expression to separate them from the tables, should be:
"(?\\s(CONSTRAINT \\[[a-z0-1_]*?\\] )?FOREIGN KEY.*?\\(.*?\\) REFERENCES .*?\\(.*?\\)(?:\\s*ON (?:DELETE|UPDATE) CASCADE\\s*)*(?:,)?)"
|
|
|
|
 |
|
 |
I use this improved regexp. It can detect foreign keys without CONSTRAINT word (based on before message) and also works with "NOT FOR REPLICATION" clause:
"(?\\s(CONSTRAINT \\[[a-z0-1_]*?\\] )?FOREIGN KEY.*?\\(.*?\\) REFERENCES .*?\\(.*?\\)(?:\\s*ON (?:DELETE|UPDATE) CASCADE\\s*)*(?:\\s*NOT( )*FOR( )*REPLICATION\\s*)*(?:,)?)"
|
|
|
|
 |
|
 |
I found a bug with scripts that contain grants. It messes up the regular expressions. Here is an example:
GRANT CREATE FUNCTION , CREATE TABLE , CREATE VIEW , CREATE PROCEDURE , DUMP DATABASE , CREATE DEFAULT , DUMP TRANSACTION , CREATE RULE TO [admincont]
GO
Since the RE's contain create ... this matches result and causes exception. I put a quickfix in code to get around it but the RE should be modified instead. The fix is as follows (starting @ line 196 of Program.cs):
...
// For Views and StoredProcs: Include DROP statement
/**BEGIN BUGFIX **/
if (objectname.Contains("\r\n"))
continue; //Hack to skip grant statement
/**END BUGFIX **/
if (groupName == "Views" || groupName == "StoredProcs")
...
|
|
|
|
 |
|
 |
Firstly, thanks for a very good article. It highlights the need for some sort of change control over databases and provides a tool for doing this. I have worked on several projects with databases. Version control for application source code (VB, C++, C# etc) was very strictly controlled but the databases were a free for all ie no version control.
FWIW, we use SQL Compare from Red-Gate Software (www.Red-gate.com). It is a commercial product but, IMHO, it is well worth the money. We integrate it into our nightly builds to take a snapshot of the database and these are then checked into VSS.
Trevor D'Arcy-Evans
|
|
|
|
 |