Showing posts with label SQL Server 2005. Show all posts
Showing posts with label SQL Server 2005. Show all posts

Monday, April 13, 2009

How to copy SQL Server DBMail configuration to another server

I'm setting up a new SQL Server from scratch and wanted to copy the existing DBMail configuration from the old server. I did some searches and the best I could find were pointers to the msdb.dbo.sysmail_* system tables. I did some trial and error and got everything copied over, so here's how I did it.
  1. Log into the new server
  2. Create a server link from the new server to the old server
  3. Copy the DBMail configuration
I had to log into the new server and do the server link there. From my workstation SQL Server considered it a redirection, and that is a security violation. Save yourself some headaches and just start at the new server. Note that the following SQL script will delete any existing DBMail configuration in the target SQL Server. If you want to keep the existing configuration you'll need to take out the DELETE and SET IDENTITY_INSERT statements and manipulate the account_id and profile_id in the related tables.

SET IDENTITY_INSERT sysmail_account ON
INSERT INTO sysmail_account (account_id, [name], [description], email_address, display_name, replyto_address, last_mod_datetime, last_mod_user)
SELECT * FROM oldserver.msdb.dbo.sysmail_account
SET IDENTITY_INSERT sysmail_account OFF
GO

DELETE sysmail_configuration
GO
INSERT INTO sysmail_configuration (paramname, paramvalue, [description], last_mod_datetime, last_mod_user)
SELECT * FROM oldserver.msdb.dbo.sysmail_configuration
GO

DELETE FROM sysmail_profile
GO
SET IDENTITY_INSERT sysmail_profile ON
INSERT INTO sysmail_profile (profile_id, [name], [description], last_mod_datetime, last_mod_user)
SELECT * FROM oldserver.msdb.dbo.sysmail_profile
SET IDENTITY_INSERT sysmail_profile OFF
GO

DELETE FROM sysmail_principalprofile
GO
INSERT INTO sysmail_principalprofile (profile_id, principal_sid, is_default, last_mod_datetime, last_mod_user)
SELECT * FROM oldserver.msdb.dbo.sysmail_principalprofile
GO

DELETE FROM sysmail_profileaccount
GO
INSERT INTO sysmail_profileaccount (profile_id, account_id, sequence_number, last_mod_datetime, last_mod_user)
SELECT * FROM oldserver.msdb.dbo.sysmail_profileaccount
GO

DELETE FROM sysmail_servertype
GO
INSERT INTO sysmail_servertype (servertype, is_incoming, is_outgoing, last_mod_datetime, last_mod_user)
SELECT * FROM oldserver.msdb.dbo.sysmail_servertype
GO

DELETE FROM sysmail_server
GO
INSERT INTO sysmail_server (account_id, servertype, servername, port, username, credential_id, use_default_credentials,
enable_ssl, flags, last_mod_datetime, last_mod_user)
SELECT * FROM oldserver.msdb.dbo.sysmail_server
GO

Tuesday, February 26, 2008

Using SQL Server 2000 DTS packages on SQL Server 2005 -- without SSIS

SQL Server 2005's Integration Services is a pain to get going. Most people agree that SQL Server 2000's Data Transformation Services (DTS) were much easier to work with. So maybe you inherited an existing infrastructure that uses SQL Server 2000 and you want to upgrade it to SQL Server 2005 but you hesitate because of SSIS. Or maybe you have a DTS package that runs perfectly fine, so you keep around a SQL Server 2000 box just for that purpose.

Bridge the gap with the Feature Pack for Microsoft SQL Server 2005 - April 2006. Specifically you want the Microsoft SQL Server 2000 DTS Designer Components. After installing this on a computer with SQL Server Management Studio 2005 you will be able to edit and run DTS packages.

Tuesday, June 05, 2007

mimicking Readers and Authors in SQL Server 2005

One of Notes and Domino's greatest strengths is the incredible security model. I've also come to appreciate how powerful it is to have that security be integrated with the application rather than having to rely on the Domino Directory. Another boon is being able to define readers and authors at the document level. Imagine if you will that Notes did not have Readers or Authors fields. Your only option for limiting access to Notes documents is solely at the view level, then relying on UI elements (computed framesets, computed embedded views, etc.) to control which view gets seen by each group of users. Ugly, right?

SQL Server 2005 does not natively implement row- or cell-level security, so that's exactly where you are in a MS development world. The security is only granular down to the table level, then you have to start using UI techniques to filter it and control access to data. And you're just praying that nobody realizes they can use Excel to connect to your database and bypass all your front end business logic, or you have to build in an interface layer that is aware of how the database is being accessed. All in all, it's pretty ugly to try to support the business use cases of letting people only edit certain records in a table.

It's not quite as bleak as I make it sound. Microsoft has published a set of instructions for hacking row-level security into SQL Server 2005. Basically it's roll-your-own authorization and while it's not horribly convoluted, it is tedious and does have to be reimplemented for every database where you want to use it. Oh, and there is no UI provided. You get to build that, and come up with a way to secure that, too. :-)