Generating script of database from source control TFS folder - tfs

I have database objects in source control like there is separate file of each procedure table and function
I want to create one Database script like which is generate from SSMS though generate script
How can i generate such script from TFS

SQL Compare will do this for you, although it depends whether it can read your file format. However, I don't see why this should be a problem asssuming the files are SQL creation scripts.
Once you've downloaded and installed SQL Compare, load your folder of scripts on the left hand side datasource (using the source control/scripts folder selection), and put a put a blank database on the right hand side datasource (just create one in SSMS). Do a comparison, run through the deployment wizard, and you'll be able to save off a single script that includes all of your objects in correct dependency order.
The tool has a 14=day fully functional trial so you'll be able to easily discover whether this works for you.

Related

Where are my Local SQL Server Express Database Files?

I read that my Local SQL Server Express Database Files should be located here (since user on my machine is "bclay"):
C:\Users\bclay\AppData\Local\Microsoft\Microsoft SQL Server Local
DB\Instances\MSSQLLocalDB
...but that can't be, as the newest file there is over 2 months old, and I updated SQL Server Express data today (via my C# Winforms app, created with Visual Studio 2019). How can I sleuth out where those files are, so I can back them up?
UPDATE
Using the answer from marc_s, I was able to get that from Visual Studio's Server Explorer:
UPDATE 2
Okay, this seems bizarre: I navigate to that location in Windows Explorer, and it won't show me what's in the \Data subfolder. Although I have selected the Data subfolder, it is showing me what's in the Installs subfolder below it, and when I right-click the Data subfolder to czech out its properties, it tells me I don't have the credentials to view it:
How can I backup the .mdf file if I can't even see it?
UPDATE 3
I did a hard-drive-wide search for all *.mdf files, and it does not "find" (show me) my tables. The only ones that could be related are the top ones here, but they have generic names:
UPDATE 4
I think it was marc_s that mentioned somewhere to use MS SQL Server Management Studio, and to select Task > Backup. I downloaded/installed it, and it seemed to work: it did create a Backup folder in the expected location. I see that it was created today, 10/1/2020, but I still can't see anything in the folder, thus I can't copy anything from it. Here's what I see (the contents of the last-selected folder) when I select the "Backup" folder:
In SSMS, if you're connected to the database in question, you can run this query
SELECT *
FROM sys.database_files
and the physical_name column in the result set will show you the path of the files in question
As #marc_s said, since you've found where are located the MDB file, just copy them on your USB stick and you are done.

Sync references with TFs in VS database projects

In db projects, when you add a database dac-pac for example as a reference use in a view to reference a third party database, that seems to be valid only for your local copy.
In VS 2015 I can;t seem to find how you add that as a build so that it syncs and compares with the version you store in source control.
If I check out a team project, create a view referencing a third party DB, create a dac-pac for that DB, add it as a database reference, save, build, check in, by default that reference isn't checked in to the server for another developer to check out in the latest version and therefor they will get reference errors.
Does anyone know how to sync these? I can't find an option to do so!
Also, it would be nice to be able to edit the dam things, For example if they are on a different server you must define that. But say the server changes, you can only edit it in your publish profile, however if you do that but someone else doesn't it will flag as a change for them.
You'd better add the .dacpac file to TFS version control. When others check out from other machines, get down the .dacpac file together with that db project.
Make sure that when other check out that file and the db project to their local machine, the relative path between them are same with that in your environment. Actually, in the .sqlproj file of your db project, it has defined the relationship.
For example, I put the .dacpac file under a folder named "DACPAC" and this folder is at the same level of my solution folder.
In the .sqlproj file:
<ArtifactReference Include="..\..\DACPAC\TestDB.dacpac">
<HintPath>..\..\DACPAC\TestDB.dacpac</HintPath>
......
</ArtifactReference>
Note: The "..\" mean go to the uplevel path from where the .sqlproj at. It has 2 "..\", so go 2 uplevels.

Fix build vNext after collection move

I moved a team project collection to a new server. Everything is fine in Visual Studio and the web site, but the build is trying to retrieve source code form the old server.
In the build definition I see no place to set the collection URI. There is a System.TeamFoundationCollectionUri variable but it's read only, trying to set it in Variables causes an An item with the same key has already been added. error on build.
Trying to add a new mapping in Repository works so the (web/app) server is aware that the source code moved, but the old location seems to be left somewhere in the build definition.
Is there any way to fix that? Without re-creating all build definitions I mean.
There is nothing visible in the web interface, but you can see the server name in the TFS SQL database. The column Repository is a nvarchar(MAX) containing all the mappings and the server name.
I fixed the server name with a replace in SQL and it works now.

ssis packages modifying files under source control

This is more of a hypothetical question as I am sure this is not a very good way to do things.
Say I have an SSIS package, under source control in TFS, that needs to read and modify some files, say a csv. how does it handle modifying the csv if the csv is also under source control in TFS?
i don't have a complete understanding of how it works, but i assume the csv would be under write protection until it is checked out. Does the ssis package just error out when attempting to write to a write protected file? Having to modify the SSIS packages to somehow get around the write protection would require a lot of work as all the these packages are already written and being added to source control now. alternatively, I assume there is some kind of settings you can do in TFS to turn off write protection on your local copy or automatically check out a file if it is being modified.
is the real solution to just keep the input and output files from the SSIS package outside of source control (as there is probably questionable justification for them to be there in the first place?)
TFS is integrated into Visual Studio. When you edit a package, VS checks it out of TFS for you and you can use Visual Studio's interface to check it back in.
In VS, Tools/Options/Source Control sets up the source control provider. File/Source Control is where you manage the connection to the project.
If you change your workspace over to a local workspace the read only attribute is removed for all files.
If however you need to edit the file in a normal workspace why I'd it under source control at all? A better way would to have separate files for DataIn, DataOut, and DataCompare. You should have DatIn and DataCompare under source control, but DataOut should be generated.
It is not recommended to have any generated files under source control.

Generate text file from change set details in TFS

I have database script folder in TFS.Developers add and changed the script files. I want to generate single text file when I specify the two change sets. Is there any possibility doing that in TFS 2010.
You can use the TFS API to query the code history, and pull out the data that way (you'd have to write the code to do this yourself).
The better way to manage updating databases is to use a Visual Studio Database Project (aka SSDT) and let the tooling do this for you.

Resources