Skip to main content

How to Backup using SQL Server Data

 Sometimes Task->Generate Scripts takes too time to backup especially when you want to backup only selected tables in the database. This can be done easily with bcp, issuing the command in your power shell dumps the data in tab-delimited values into a file.

\> bcp "DATABASE.dbo.TABLE" out "C:\Downloads\TABLE.sql" -c -S "HOSTNAME" -U USERNAME -P PASSWORD

Hope this helps, this is very useful for migrating data and for seeders where some tables are only needed to be seeded into the database as dependent values for other tables. We are heavily using this technique for testing. As for reference, here's our use case

  • Dump data into .sql files
  • Seed using QueryFromFile
  • Run automation; this can insert new values to other tables based from the seed data from .sql file
  • Rollback new values
We need to rollback each time since we want to have data the same as it was so we can run each time and expect the same results for our testing. If not, there should be error somewhere or a bug introduced in the new code that we need to fix.

That's it for now. See you in the next blog. Take care everyone!

Comments

Popular posts from this blog

My Linux Journey: Hello World with .NET

Today marks the beginning of my journey into the world of Linux. As a lifelong Windows user, venturing into a new operating system felt like stepping into uncharted territory. But armed with curiosity and a desire to explore, I took the leap. My first task? A simple "Hello World" program using .NET. With the installation of .NET 8.0 on my Linux machine, I was ready to dive in. I created a new directory for my project, aptly named "helloworld," and ran the following commands: dotnet new console -o helloworld cd helloworld dotnet run And just like that, the words "Hello World" appeared on my terminal screen, a small victory but a significant milestone in my Linux journey. As I reflect on this humble beginning, I am reminded of the endless possibilities that lie ahead. From mastering the command line to exploring the vast ecosystem of open-source tools and technologies, there is much to learn and discover. Join me as I embark on this exciting adventure, one c...

The Importance of Counting Table Rows in Database Management

 In the realm of database management, where accuracy and efficiency are paramount, counting table rows stands as a foundational practice. It serves as a reliable indicator of database health, offering insights into data integrity, application performance, and system behavior. In this blog post, we explore the significance of counting table rows and its practical applications in database management. Understanding the Importance Counting table rows may seem like a simple task, but its implications are profound. Here's why it's crucial: Data Integrity Verification : By comparing row counts before and after executing operations like inserts, updates, or deletions, you can ensure data integrity. Any discrepancies indicate potential issues that require investigation. Performance Monitoring : Monitoring row counts provides valuable insights into application performance. Sudden spikes or drops in row counts may indicate inefficient queries, bottlenecks, or data processing issues. Capac...

Python Hydrology

Recently I'm learning Python and encountered the Hydrology book. Had to upgrade some of python packages and some libraries needed to get working with the book. There is an instruction though about mostly using pip install packages need for the book. The problem is I can't get it work. It's missing some things so I did a little google and hopefully this is a compilation of the things I need to work with the examples of the book. First off, I updated the apt-get $ sudo apt-get update Next is I installed the pip package manager. I'm not too sure but I have Ubuntu 10 and it doesn't have the pip installed. So I installed using the command below. $ sudo apt-get install python-pip Now the development packages for python. $ sudo apt-get install python-dev Most of the examples uses the scientific number packages so I installed numpy and other packages I'm not quite aware of. It's just that some of the examples probably in the later part of the book use...