Posts

Manage Both On-Prem and Azure Databases with SQL Server PowerShell

 

About the Presentation

Manage Both On-Prem and Azure Databases with SQL Server PowerShell

In today’s world, you’re more likely to have databases both on premises and in the cloud. Managing databases in different environments can make your life more complicated, but with the new PowerShell cmdlets introduced with SQL Server 2014, it actually becomes easier.

In this session, we’ll introduce you to the new cmdlets and show you how to manage your on-prem and Azure databases consistently.

Session Level: Intermediate

This session was presented at PASS Summit 2014.
Manage Both On-Prem and Azure Databases with SQL Server PowerShell

Download the Presentation

Manage Both On-Prem and Azure Databases with SQL Server PowerShell

Presentations (Upcoming & Past)

 

About the Author

Microsoft SQL Server MVP and Practice Leader

Allen White

Allen White is an UpSearch Alum and Microsoft SQL Server MVP.  For over 30 years, Allen has specialized in developing applications that manage the movement of data and maximize data's usefulness. Allen excels at communicating highly technical information using language that results in increased client engagement and understanding, regardless of technical competency.

Allen has been working with relational database systems for over 20 years. He has architected database solutions in application areas like retail point-of-sale (POS), POS audit, loss prevention, logistics, school district information management, purchasing and asset inventory and runtime analytics. Allen thrives on providing comprehensive solutions to information management problems across a great variety of application environments.

About UpSearch

up-social-round

UpSearch is a company of data management and analytics experts who enable digital maturity with Microsoft’s technologies. Its mission is to enable every leader to unlock data’s full potential. UpSearch provides full lifecycle support for SQL Server, SQL Server in Azure (IaaS), Azure SQL DB (PaaS), Azure SQL DW (PaaS), Analytics Platform System (APS), and Power BI.

PowerShell 101 for the SQL Server DBA

 

About the Presentation

PowerShell 101 for the SQL Server DBAThe more you have to manage, the more likely you’ll want to automate your processes. PowerShell scripting language will make you truly effective at managing lots of servers. But it’s more than just a scripting language – it’s an interactive shell that stores data for you and allows you to implement ad-hoc solutions quickly and easily. Within the PowerShell environment you can easily manage both SQL Server instances and the Windows servers themselves, giving you a ‘best of both worlds’ environment that puts you in control. This session will introduce you to SQL Server PowerShell and show you how to use it to manage SQL Server across many instances.

Session Level: Intermediate

Download the Presentation

PowerShell 101 for the SQL Server DBA

Presentations (Upcoming & Past)

 

About the Author

Microsoft SQL Server MVP and Practice Leader

Allen White

Allen White is an UpSearch Alum and Microsoft SQL Server MVP.  For over 30 years, Allen has specialized in developing applications that manage the movement of data and maximize data's usefulness. Allen excels at communicating highly technical information using language that results in increased client engagement and understanding, regardless of technical competency.

Allen has been working with relational database systems for over 20 years. He has architected database solutions in application areas like retail point-of-sale (POS), POS audit, loss prevention, logistics, school district information management, purchasing and asset inventory and runtime analytics. Allen thrives on providing comprehensive solutions to information management problems across a great variety of application environments.

About UpSearch

up-social-round

UpSearch is a company of data management and analytics experts who enable digital maturity with Microsoft’s technologies. Its mission is to enable every leader to unlock data’s full potential. UpSearch provides full lifecycle support for SQL Server, SQL Server in Azure (IaaS), Azure SQL DB (PaaS), Azure SQL DW (PaaS), Analytics Platform System (APS), and Power BI.

 

SQL Server Service Broker Basics Part Two

Service Broker is not a black box. SQL Server Service Broker Basics Part Two was designed to support your messaging needs and make sense of Service Broker.

Continued from SQL Server Service Broker Basics Part One

SQL Server Service Broker Basics Part Two

Originally published on SQLBlog.com.SQL Server Service Broker Basics Part Two

In the previous post, I introduced SQL Server Service Broker Basics Part One.  In this post, I’d like to cover some of the “plumbing” – the components that allow communication between different servers running Service Broker.

Endpoints. There needs to be a channel for the communications coming in and out of the server, and in the IP world that channel exists in the form of a port. You define the port to be used by defining an Endpoint in the master database.

CREATE ENDPOINT IntEndpoint
STATE = STARTED
AS TCP ( LISTENER_PORT = 4022 )
FOR SERVICE_BROKER (AUTHENTICATION = WINDOWS );
GO

Routes. To get from one place to another Service Broker routes need to be defined. You’ll need a route to the remote server defined in the database where your Service Broker application is running, and also one to the local server, and the latter needs to be defined in the msdb database. Defining a remote destination in your application database places the route information in sys.routes, but Service Broker always looks in msdb.sys.routes for any incoming messages to determine where they go.

USE AdventureWorks
GO

CREATE ROUTE DMZRoute 
AUTHORIZATION dbo 
WITH 
     SERVICE_NAME = N'//DMZSite/Sync/IntService',
     ADDRESS = N'TCP://SQLTBWS:4023'
GO

USE msdb;
GO

CREATE ROUTE IntRoute 
AUTHORIZATION dbo 
WITH 
     SERVICE_NAME = N'//IntSite/Sync/IntService',
     ADDRESS = N'LOCAL'
GO

One thing I hadn’t addressed in my last post was message security. Service Broker allows you to encrypt all messages, preventing network sniffers from discovering the data being sent. To enable this I created certificates at each site, and created a database user without a login to send and receive messages. Here’s the code I used to create the local user:

USE AdventureWorks
GO

CREATE MASTER KEY
       ENCRYPTION BY PASSWORD = N'<enter REALLY secure password string here>';
GO

CREATE USER IntUser WITHOUT LOGIN;
GO
CREATE CERTIFICATE IntCert 
     AUTHORIZATION IntUser
     WITH SUBJECT = 'Int Certificate',
          EXPIRY_DATE = N'12/31/2012';

BACKUP CERTIFICATE IntCert
  TO FILE = N'E:\Certs\IntCert.cer';
GO

I did the same thing at the destination site (called DMZSite), and to allow the DMZUser to send messages to my site I’ll create a local user from the certificate created at that site.

CREATE USER DMZUser WITHOUT LOGIN;

CREATE CERTIFICATE DMZCert
   AUTHORIZATION DMZUser
   FROM FILE = N'E:\Certs\DMZCert.cer';
GO

Remote Service Binding. Once the users are established and secure, the last component required is the Remote Service Binding. This binds a remote Service Broker service to our local one, defining the security credentials to be used in the conversations.

CREATE REMOTE SERVICE BINDING [DMZBinding] 
  AUTHORIZATION dbo 
  TO SERVICE N'//DMZSite/Sync/IntService'
  WITH USER = [DMZUser]
GO

Finally, we’ll grant the SEND permission to the DMZUser to allow the remote service to send messages to our site.

GRANT SEND
      ON SERVICE::[//IntSite/Sync/IntService]
      TO DMZUser;
GO

As I mentioned before, this set of objects make up the “plumbing” that allow separate instances or servers to communicate with each other. In my next post we’ll talk about the automated activation process and walk through the steps of message handling.

Reprinted with author’s permission from SQLBlog.com.

>> Back to SQL Server Service Broker Basics Part One <<

 

UpSearch

About the Author

Microsoft SQL Server MVP and Practice Leader

Allen White

Allen White is an UpSearch Alum and Microsoft SQL Server MVP.  For over 30 years, Allen has specialized in developing applications that manage the movement of data and maximize data's usefulness. Allen excels at communicating highly technical information using language that results in increased client engagement and understanding, regardless of technical competency.

Allen has been working with relational database systems for over 20 years. He has architected database solutions in application areas like retail point-of-sale (POS), POS audit, loss prevention, logistics, school district information management, purchasing and asset inventory and runtime analytics. Allen thrives on providing comprehensive solutions to information management problems across a great variety of application environments.

About UpSearch

up-social-round

UpSearch is a company of data management and analytics experts who enable digital maturity with Microsoft’s technologies. Its mission is to enable every leader to unlock data’s full potential. UpSearch provides full lifecycle support for SQL Server, SQL Server in Azure (IaaS), Azure SQL DB (PaaS), Azure SQL DW (PaaS), Analytics Platform System (APS), and Power BI.

SQL Server Service Broker Basics Part One

Service Broker is not a black box. SQL Server Service Broker Basics Part One was designed to support your messaging needs and make sense of Service Broker.

SQL Server Service Broker Basics Part One

Originally published on SQLBlog.com.SQL Server Service Broker Basics Part One

I’m currently implementing a SQL Server Service Broker solution at a client site, and it’s been an interesting challenge, because there’s not a lot of information out there to help guide you through the process. Here I’d like to walk you through the basics.

Message Types. Service Broker sends messages asynchronously from one database to another. You can set it up to send messages between databases on a single server, or between SQL Server instances on a Windows server, or between different physical servers, whether or not they’re in the same domain. Essentially Service Broker works at the database level, the rest is handled through routing, which I’ll address in another post.

The important thing to remember is that Service Broker sends and receives messages, and then your applications (or stored procedures) handle those messages in some way. It handles them asynchronously, so the sending side doesn’t have to wait for the receiving side to acknowledge the message, and it handles them sequentially, so the messages will always arrive in the order in which they’ve been sent.

Many of the examples you’ll see use message types like “REQUESTMESSAGE” and “REPLYMESSAGE”. To me this is a disservice, because it doesn’t help you see the different ways you can use Service Broker to solve your business problems. At my client site the message types indicate the content of the message, so the receiving side can use the type to determine the action to take when the message is received. Service Broker has a built-in acknowledgement process, so you don’t need to specifically acknowledge a message, unless the application needs it. As long as the communication channels are open, the message will be delivered.

CREATE MESSAGE TYPE [//AWSync/Sync/HumanResourcesEmployee]
AUTHORIZATION dbo
VALIDATION = WELL_FORMED_XML
GO

Contracts. Once you’ve defined the types of messages that can be sent, you need to define how they’ll be delivered. Contracts define what message types are allowed to be sent, and in which direction. This means that Service Broker is secure in that it won’t process any messages types not defined in a contract, so rogue processes that attempt to try a type of SQL Injection attack against Service Broker will fail.

CREATE CONTRACT [//AWSync/Sync/IntContract]
	AUTHORIZATION dbo
	( [//AWSync/Sync/HumanResourcesEmployee] SENT BY ANY,
	  [//AWSync/Sync/PersonContact] SENT BY ANY,
      [//AWSync/Sync/PurchasingVendor] SENT BY ANY )
GO

Queues. Once the contract is defined, you can define the queue on which the messages are sent and received. The queue also defines (if you want) an automated process that will handle the messages it receives. In your Transact-SQL code you retrieve messages from the queue in the same way you read data from a table – in fact, the queue behaves just like a table in your database.

CREATE QUEUE IntQueue
   WITH
   STATUS = ON,
   RETENTION = OFF
GO

Services. The service is the glue which assigns the contract to the queue. It performs the work of actually sending the messages on the queue to their destination and receiving the messages coming from other senders.

CREATE SERVICE [//IntSite/Sync/IntService]
AUTHORIZATION IntUser
ON QUEUE IntQueue
([//AWSync/Sync/IntContract])
GO

Conversations. In its simplest form, the last thing we need is to send the message. We do that via a conversation, which is referred to in Service Broker as a DIALOG CONVERSATION or simply a DIALOG. You specify the source and destination service name, and a conversation handle (a GUID) is returned, then you SEND ON CONVERSATION using that conversation handle. The message body is usually in an XML form, and for security purposes should be encrypted.

BEGIN DIALOG @InitDlgHandle
   FROM SERVICE [//IntSite/Sync/IntService]
   TO SERVICE N'//ExtSite/Sync/IntService'
   ON CONTRACT [//AWSync/Sync/IntContract]
   WITH
	   ENCRYPTION = ON;

SEND ON CONVERSATION @InitDlgHandle
   MESSAGE TYPE [//AWSync/Sync/HumanResourcesEmployee]
   (@ChangeMsg);

Finally, you need to be able to receive the messages. Like I mentioned earlier, reading from a queue is like reading from a table, but there are some additional features in Transact-SQL to facilitate message handling. Specifically, there’s a special form of the WAITFOR command which will wait for either the arrival of a message, or timeout after a specified number of milliseconds.

WAITFOR (
	RECEIVE TOP(1)
		@ch = conversation_handle,
		@service_name = service_name,
		@service_contract_name = service_contract_name,
		@messagetypename = message_type_name,
		@messagebody = CAST(message_body AS XML)
	FROM ExtQueue
), TIMEOUT 60000

With these components you can set up messaging within a single instance of SQL Server. In my next post I’ll discuss the additional plumbing required to communicate between separate instances.

Reprinted with author’s permission from SQLBlog.com.

>> Continue Reading SQL Server Service Broker Basics Part Two <<

 

UpSearch

About the Author

Microsoft SQL Server MVP and Practice Leader

Allen White

Allen White is an UpSearch Alum and Microsoft SQL Server MVP.  For over 30 years, Allen has specialized in developing applications that manage the movement of data and maximize data's usefulness. Allen excels at communicating highly technical information using language that results in increased client engagement and understanding, regardless of technical competency.

Allen has been working with relational database systems for over 20 years. He has architected database solutions in application areas like retail point-of-sale (POS), POS audit, loss prevention, logistics, school district information management, purchasing and asset inventory and runtime analytics. Allen thrives on providing comprehensive solutions to information management problems across a great variety of application environments.

About UpSearch

up-social-round

UpSearch is a company of data management and analytics experts who enable digital maturity with Microsoft’s technologies. Its mission is to enable every leader to unlock data’s full potential. UpSearch provides full lifecycle support for SQL Server, SQL Server in Azure (IaaS), Azure SQL DB (PaaS), Azure SQL DW (PaaS), Analytics Platform System (APS), and Power BI.

Use PowerShell Remoting to Manage SQL Servers Efficiently

Allen White’s April 2014 article in SQL Server Pro magazine introduces PowerShell Remoting as a lightweight way to manage all of your servers at the same time.

Continue Reading on SQLMag.com >>

 

About the Author

Microsoft SQL Server MVP and Practice Leader

Allen White

Allen White is a Microsoft SQL Server MVP and Practice Leader at UpSearch.

For over 30 years, Allen has specialized in developing applications that manage the movement of data and maximize data’s usefulness. Allen excels at communicating highly technical information using language that results in increased client engagement and understanding, regardless of technical competency.

Allen has been working with relational database systems for over 20 years. He has architected database solutions in application areas like retail point-of-sale (POS), POS audit, loss prevention, logistics, school district information management, purchasing and asset inventory and runtime analytics. Allen thrives on providing comprehensive solutions to information management problems across a great variety of application environments.

Learn more about Allen White at  https://upsearch.com/allen-white.

 

About UpSearch

up-social-round

UpSearch provides as needed Microsoft SQL Server DBA Services across the globe. We specialize in helping leaders protect, unlock and optimize data’s value.

 

Checklists

One of the first things a pilot is taught is to use checklists. Everything from preflight to tie down after your return is covered in aviation checklists. Did you check the thickness of the brake pads? Did you actually look in the fuel tanks to see how much fuel you have (because guages can malfunction, just like everything else)? When you’re 3500 feet above the ground you can’t just pull over and see what’s wrong. (Once – on my second solo flight – had just taken off when there suddely was a loud flapping noise against the side of the plane. With a high level of anxiety I maneuvered through the pattern, got the plane back on the ground, and found I’d left the strap to my seat belt hanging out the door when I closed it, and it was hitting the side of the plane from the prop wash after I took off!)

As a DBA it’s your responsibility to ensure that everything is running properly, especially in your production environments. When things are running smoothly and you have time to think things through it’s easy to make changes without incident. Things aren’t always running smoothly when changes have to made. Sometimes you’re in the middle of a critical project and someone needs a major change. It’s easy to forget little details – things you’d normally never forget – when these requests are made. It’s moments like this when the checklist is really your friend.

We have an application that manages web sites for our trade shows, and it uses a master database for the application, and a database for each individual web site. Over the (almost) four years since we brought this application in house I’ve created hundreds of databases for the sites. Now, there are items on my checklist besides setting up the databases, because I handle those as well, but I don’t know of a business environment where you can focus on “just” the database issues.

  • Create the Datastore Directory
  • Create the Site Database
  • Configure the Global Database
  • Set up the Java Runtime Connections
  • Configure the Web Site
  • Confirm the Web Site is Working

The checklist doesn’t have to be complex (it can be if you’re passing it on to a junior DBA, but it doesn’t have to be.) It’s usually enough that you have the major steps, and some of the minor ones if they get a bit detailed. The important thing is that you have a reference to make certain you don’t miss anything when you need to get something done.

 

About the Author

Microsoft SQL Server MVP and Practice Leader

Allen White

Allen White is a Microsoft SQL Server MVP and Practice Leader at UpSearch.

For over 30 years, Allen has specialized in developing applications that manage the movement of data and maximize data’s usefulness. Allen excels at communicating highly technical information using language that results in increased client engagement and understanding, regardless of technical competency.

Allen has been working with relational database systems for almost 20 years. He has architected database solutions in application areas like retail point-of-sale (POS), POS audit, loss prevention, logistics, school district information management, purchasing and asset inventory and runtime analytics. Allen thrives on providing comprehensive solutions to information management problems across a great variety of application environments.

Learn more about Allen White at  https://upsearch.com/allen-white.

 

About UpSearch

up-social-round

UpSearch provides as needed Microsoft SQL Server DBA Services across the globe. We specialize in helping leaders protect, unlock and optimize data’s value.