Keep Publication while migrating database in SQL Server 2008 R2 [closed] - sql-server

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a large database with merge-replication on it that needs to be moved to a different server. There is one publisher, but there are close to 200 subscribers, so I don't want to recreate them all manually.
Is there a way to make this move so that I don't have to recreate the publication and subscribers. I read this link, but I wasn't sure if that's what I'm looking for.
If you need more details, let me know. Thanks!

Hopefully, you can find the original "setup subscriber" script. And piggy back on the msdn article below to "variable up" your existing script.
If not, you could create the scripts manually. Not ideal, but better than 200 manual setups through the GUI.
Here is a link to kinda what I'm suggesting: (the msdn link below).
http://msdn.microsoft.com/en-us/library/ms147302.aspx
-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables
-- on the command line and in SQL Server Management Studio, see the
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".
So you get 1 subscriber working correctly, then you can command line call the scripts and just pass in the other 199 config values (servername/database name, etc).
I would NEVER rely on manual steps to reproduce replication. You'll never "from memory" get the same result twice. There are just too many options, IMHO, and too many "fat finger" mistakes to be made.
EDIT:
http://msdn.microsoft.com/en-us/library/ms152483.aspx
Maybe that can help.
You're looking for a "is there a way to 'script out' publication setup"? (and then subscriber).
If so, you'll have your pre-sql-cmd starting point. Then sqlcmd up the variables.
And you'll know how to get perfect and exact subscribers in the process.

Related

delphi adoquery filter with listbox items [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
this is final but already not filter
anyone has idea about my filter problem
begin
adoquery1.SQL.CLEAR;
adoquery1.SQL.Add('select * FROM gunsonu ');
adoquery1.SQL.Add('where TARIH like :TRH');
adoquery1.Parameters.ParamByName('TRH').Value:=(PlannerDatePicker1.text);
for i := 0 to form3.ListBox1.Items.Count-1 do
adoquery1.SQL.Add(' and VLIM <> '+QuotedStr(form3.ListBox1.items[i]));
end;
adoquery1.Open;
frxReport1.ShowReport(true);
The best way to set up queries from a Delphi app against an MS Sql Server isn't to keep modifying code in the app that constructs the query until running it returns the results you're hoping for. One of the problems with the Delphi rapid compile/run cycle is that it encourages trial and error, which is
no substitute for getting things working properly.
It's better to separate the SQL-constructing task from the coding one for two reasons:
The Sql Server client-side utilities (e.g. Sql Server Management Studio or the old ISql/W "Query Analyzer") are better tools for the Sql-construction task, they have access to the server's execution plan, profiler, etc. But if you don't have one of those available, over the years, Delphi has included some kind of "Data Explorer" utility to run queries against a variety of servers - in recent XE versions, there's a Firedac one under FireDac | Explorer from the IDE menu.
Using one of those tools, you have the Sql query which is actually sent to the server right on the screen in front of you. A frequent source of error when trying to set the Sql up in Delphi code, especially for a beginner, is that the Sql query sent to the server isn't necessarily what you assume it is. Judging by the examples that appear in qs on SO, they're frequently riddled with syntactic or semantic errors, especially when the Sql is supposed to contain quotation marks (the Delphi IDE's Watch and Evaluate windows don't provide a good form for viewing Sql). Creating the query in a Sql querying tool, you get the chance to see exactly what the query is, and to get feedback from the tool regarding syntax errors, etc.
It's easier using those tools to experiment with the best way to parameterize your query.
What's the point of 3? Well, one thing is that parameterized queries are generally better optimized by the server than an ad hoc one, though admittedly not all queries can be expressed in a parameterized form (e.g. you can't parameterize which column or table you're querying against). The other thing is that it helps minimise your exposure to Sql-Injection (see https://en.wikipedia.org/wiki/SQL_injection).
Once you've got your query working as you're expecting in a client-side Sql tool like those above is the time to write the code to execute it from your Delphi app, not before.

How to backup SQL Server 2012 database to flat file and again restore the flat file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Is it possible to backup SQL Server 2012 database to flat file and again restore the flat file to bring up the database?
If you absolutely have to create a flat (text) file instead of a true database backup, you can do it via scripting. In this case, you'd want to script both schema and data, or simply the data if you have no need for a schema script.
Through the UI, this is done via the database scripting interface (right-click the database -> tasks -> generate script). Select the objects you're interested in (or the entire database), then on the 'set scripting options' form, click the 'Advanced' button. Scroll down until "Types of data to script" is visible, then pick either "Schema and data" or "Data Only":
The output will be a SQL script. If you examine the script, you'll see that after the schema definition statements (if you chose to generate these) are INSERT statements to re-create the data.
Be aware, however, that this method is by no means optimal. Records with unusual contents (e.g. characters that will break the insert statement) will not be handled well when you try to rebuild the data.
(Commenters... be aware I am addressing the question itself, not the "why?" which the question begs.)
EDIT: If you want to do this though a maintenance plan, you'll need to use a third-party tool to generate the INSERT statements. There are several: SQLPubWiz is one.
I don't know your experience with SQL Server, so what I normally do is:
go to my DB -> Tasks -> Generate script -> and script the entire database.
This is to save the structure of the db, so you can build it on a new pc.
go again to the DB -> Tasks -> Export Data -> and here I choose as destination Access instead of Flat File, since I have bad experiences with Flat Files.
Once the export is done, I import it the same way as above into my new db on the new pc.
I hope this is helpful.

How to send the reports through E-mail and Windows file simultaneously in SQL server 2008 report services [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm using the SQL server 2008.
The scenario is:
We have about two hundred reports to generate daily, and it need plenty of time to query in DB and refine the data. We hope the reports can be sent from e-mail and saved at the windows file system at the same time. So the method need two different subscription for the two ways of delivery is not acceptable.
Wondering if we can make it by customizing the subscription directly or write some dll to enhance it(like allow us selecting a new customized delivery when edit the subscription). Could u pls give me some ideas on it? If not, we have to write a new program to do it..but it needs effort..
One option would be to cache the reports so that they run quickly the second time.
Another option would be to put the files in a Windows file share and use SSIS SendMail to pick up the files and email them out.
One more option is to write your own report runner that runs the reports and deals with them as you want. I was unsatified with the Reporting Services scheduler options and did it this way. It isn't as hard as you might think and Microsoft has some code that will get you started.

SQL Server Documentation Generator Tool [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm working on a large SQL Server database with no documentation. Is there a good, preferably free, documentation generator tool I can use to get my head around it.
One tool that I'm using more and more to do this sort of thing is LinqPad (www.linqpad.net). This is far more than just a Linq tool. It is very good at allowing you to drill down through table relationships, as long as FK's are properly in place. This tool is free.
On the non-free side, we also use Red-Gates SQL Doc (http://www.red-gate.com/products/sql-development/sql-doc/). Excellent tool.
You might want to have a look at my new (non-free, sorry) tool - LiveDoco - it's a web app that can be installed on an intranet IIS or even on a local IIS server and then you can just use your favorite browser to connect to a SQL Server database and see its structure/metadata, edit object descriptions or even search in DB object names (tables, columns, functions and their parameters etc.) and in the extended properties where the descriptions are usually stored (under “MS_Description”). And finally there is an export feature you can use to export all extended properties to a SQL file that you can run on a different DB of the same/similar structure to import/update your descriptions/notes there.
There is a fully functional (but read-only) online demo at http://www.livedoco.com.
This link will take you directly to the Person.Contact.ContactID column in the AdventureWorks sample DB from MS: http://demo.livedoco.com/livedoco/Explorer?Server=(local)%5Csql2k8xpress&Database=AdventureWorks#/?L0Name=Person&L1Name=Contact&L2Name=COLUMN_ContactID

How to roll back delete operation sql server? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have an input page in my C# application whereby my boss can enter sales info.
This page also has a clear button, which clears the contents of the table in the database. This clear button was convenient for testing, however now in hindsight a mistake.
All the records in the table have been deleted. There are no backups either.
Long shot, but is there any way of recovering this data using only SQL Server 2008?
If you still have the transaction logs, there are some tools, but these will cost some ...
See
How to undo a delete operation in SQL Server 2005?
and
https://web.archive.org/web/20080215075500/http://sqlserver2000.databases.aspfaq.com/how-do-i-recover-data-from-sql-server-s-log-files.html
Edit : Looks like Redgate is SQL 2000 only. Which leaves Apex. And if your clear function uses TRUNCATE, you are up the creek.
Edit:( 2008 support)
SQL Data Compare Professional
This version of SQL Data Compare, you can compare a live database with or against backup files and synchronize data and deleted tables with their data contents from the backup file or backup file set to the live database.
Redgate even say this should do the same job, and that is why they have not come with any new version.
Will probably need a backup or transaction log ....
See this subject.

Resources