Best way to generate random data into a database - sql

What is the best method to generate random data in SQL database lke name surnames tel no etc?
Is there any tool available that can do this for you?
Basically I have a database and I would like to fill it out with demo data....
Thanks!

If SQL Server Redgate SQL Server SQL Data Generator does this.

http://www.generatedata.com/
This tool gives us the ability to download in a variety of formats, including the command for inclusion in the database

Related

compare data in sql server databases

I have a sql sever database on 2 servers. The structure of it is the same on both. A problem that I have is that I want to copy data between both databases - but the problem is I need to drop and recreate all the constraints first.
Any quick and easy way to script the differences between both databases, regarding data?
Yes, stop spending hours and hours trying to write a script that does this. Use a tried and true tool that handles all of that effort and debugging for you:
http://www.red-gate.com/products/sql-development/sql-data-compare/
There is a trial edition and there are several alternatives as well. Read this to see why you shouldn't re-invent the wheel:
http://madelinebertrand.com/2012/04/20/re-blog-the-cost-of-reinventing-the-wheel/
Just throwing my 2 cents in. If you have Visual Studio 2010 Premium or Ultimate, you can actually use feature called "Data Compare" to compare data between two databases. And it will be able to generate update script for target database as well.
I can only repeat the same opinion as Aaron Bertrand has, and to add to that, I had success using XSQL for this kind of task.
As far as I remember, it was a nice, consistent tool to use...
First you would need to turn the constraints off by altering the table in question such as:
alter table [table name] nocheck constraint all
Then you could query from the other server by linking or query directly using the following format:
select [cols] from [local table], [remote server.remote DB.remote table]

Microsoft SQL Server: How to export data from a database and import them to another database?

How can I export all of my rows in a table to sql script in Microsoft SQL Server 2005 and then import them to another database?
Thanks in advance
If you moving it to another sql db you can right click the database you want and choose tasks -> generate scripts. That will launch a a wizard - follow along, choose the option to script all tables and data. Then execute that script in the new db(assuming that you've already created one with the same name)
If you can't find a data import/export tool that will work in your particular circumstances, it's possible to write plain SQL SELECT queries that will generate SQL INSERT statements. In this way it's possible to "export" all your data to a script file that can be run against the destination database. It's kind of an ugly hack, but it's simple and it works if you don't have a lot of data to move. See my answer to this question for details: Export SQL Server 2005 query result to SQL INSERT statement?
Note that this method assumes that the destination table already exists. But it's pretty straightforward to generate table creation scripts, as J Cory's answer has already shown.
There's a command line tool available to dump your data from particular tables into a SQL script that be executed against a different database:
http://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/
I don't believe SQL Management Studio Express supports data scripting (as your screenshot on J Cory's answer shows), but the full version does support that feature. In either case, the command line tool should accomplish what you need.

SQL schema Table compare

I'm looking for an app that will compare the layout of 2 SQL tables. When developing in a DEV environment, I need a tool that will make the production tables exactly like the DEV tables (the layout).
SQL Compare from Red Gate and ERWin are two tools that work. Neither are free
I wrote a program called "SQL Server Comparison Tool" (SCT for short). You can try it for free for 30 days; I can extend that period to 90 days.
You can download SCT from www.sql-server-tool.com
SCT can compare both structure and data. You can "record" comparisons so that you can "re-play" them later without need for entering parameters again.
BeyondCompare can do this for you I believe.
You can try to use the SQL Examiner tool from the SQL Accessories.

Move Data from Oracle to SQL Server

I would like to copy parts of an Oracle DB to a SQL Server DB. I need to move the data because the Oracle box is being decommissioned. I only need the data for reference purposes so don't need indexes or stored procedures or contstaints, etc. All I need is the data.
I have a link to the Oracle DB in SQL Server. I have tested the following query, which seemed to work just fine:
select
*
into
NewTableName
from
linkedserver.OracleTable
I was wondering if there are any potential issues with using this approach?
Using SSIS (sql integration services) may be a good alternative especially if your table names are the same on both servers. Use the import wizard via and it should create the destination tables for you and let you edit any mappings.
The only issue I see with that is you will need to execute that of course for each and every table you need. Glad you are decommissioning the oracle server :-). Otherwise if you are not concerned with indexes or any of the existing sprocs I don't see any issue in what you are doing.
The "select " approach could be very slow if tables are large. Consider writing pro*C in that case or use Fastreader http://www.wisdomforce.com/products-FastReader.html
A faster and easier approach might be to use the Data Transformation Services, depending on the number of objects you're trying to copy over.

How do I make a script in SQL Management Studio 2005?

I have a table in an MS SQL Server db. I want to create a script that will put the table and all records into another db. So I right-click the table in Management Studio and select Create-To new query editor... but all I get is the table structure.
How exactly do I get the values too?
One of the things I really like about the tools for MySQL that SQL Server is missing out of the box to be certain.
You can use a script to do it however.
You might also want to consider using something like Red-Gate SQL Compare and Red-Gate SQL Data Compare. They aren't cheap tools, priced at $395 each (for the standard editions), but there are 14 day free trials available for download, and they make copying schema and data from one SQL Server to another very easy.
If both are on the same machine (or on different machines but the servers are linked)
you can create the table with the script you can generate automatically and do this to copy the data:
INSERT INTO [destinationdb].[dbo].[destinationtable] SELECT *
FROM [originaldb].[dbo].[originaltable]
(Prepend [servername] to the database name if you'll be using linked servers)
Another option is to enable xp_cmdshell (do with care, it's relaxing security constraints) and use the bcp command line utility from the management studio to create copies you can then import into the other database/server. You can do that directly from the shell as well and do not need to enable xp_cmdshell in that case, of course.
it doesn't really create a "SQL script" but it does the job :
select the database in the object explorer
right click
select import/export data
follow the wizard
at the end of the process you can save the "integration service package" to reuse it
later you can modify the details by opening the .dtsx
(it will take care of security, and won't cost one more penny, it's seems we have to compete with other answers :) )
hope it helps.