Sql-Server

SDU Tools: Script SQL Server Table

In our free SDU Tools for developers and DBAs, we’ve added a lot of scripting tools. The tool that I’m describing today is one of the most sophisticated tools in our scripting options. It’s ScriptTable.

It’s very flexible. For example, it can change the name of the table, or the schema that it’s in. It can force ANSI_NULLS and ANSI_PADDING on or off. It can change user-defined data types to their base types, change compression strategies, and more.

2019-01-30

T-SQL 101: 2 What is T-SQL?

In the first blog post of this introductory series for learning T-SQL, I talked about what SQL is. That then raises the obvious question, about what T-SQL is.

Well the promise of SQL was that we’d have one language, and it would work with all databases. Did that end up working? Well, sort of.

Committees, even the ANSI committees, are notoriously hard to make progress in. Everyone has no doubt heard the joke about a camel being a horse designed by a committee.

2019-01-28

Bring your reports and analytics to life. Learn SQL Server spatial now.

I love working with SQL Server spatial. Don’t just use boring tables and charts. Spatial data can really help to bring your reports and analytics to life.  Don’t assume spatial is just about maps. (It’s not). Don’t assume you don’t have spatial data. (I’m sure you have addresses, locations, etc.)

We’ve been working hard lately on getting many of our popular in-person courses, converted to being available online and on-demand. We’re really proud to now have SQL Server Spatial for Developers and DBAs available.

2019-01-25

Shortcut: Tab groups in SQL Server Management Studio

In a previous post, I showed how you might use split windows to allow you to work on different parts of a single query at the same time.

But what if you need to work on two queries and see parts of both of them?

That’s where tab groups can help you. You can create both vertical and horizontal groups. For me, the most useful is typically side-by-side vertically, for when I’m comparing two sections of code.

2019-01-24

SDU Tools: Script SQL Logins for SQL Server

In our free SDU Tools for developers and DBAs, we’ve added a lot of scripting tools. To script out SQL authenticated logins (as opposed to Windows logins), we have ScriptSQLLogins.

You can see how to use it in the main image above. It’s a function, that takes a list of the logins to script. You can pass the value ALL or a comma-delimited list.

Importantly, as well as the login and the hashed password, it also scripts other details:

2019-01-23

T-SQL 101: 1 What is SQL?

For some time, I’ve been thinking that I should create a series of blog posts about the T-SQL language, from a beginner’s perspective. For the next few months, my Monday posts will be intro-level T-SQL.

The obvious topic to start with then, is what is SQL in the first place?

When I started working with databases in the 1980’s, there were many, many different types of database. Each database had its own language that was used to get information back out of the database, or to put the information into the database in the first place.

2019-01-21

Shortcut: Split query windows in SQL Server Management Studio

If you are working with really long script files in SQL Server Management Studio (SSMS), you might need to work on more than one part of the script at the same time. Perhaps you need to work on a function, and also on the code that calls the function.

On the Window menu, there is a Split option.

When you first do this, you’ll see a split window with the same query at top and bottom:

2019-01-17

SDU Tools: Script Server Role members in SQL Server

In our free SDU Tools for developers and DBAs, there’s another useful scripting tool. It scripts out the logins that are members of server roles. It’s called ScriptServerRoleMembers.

One key advantage of having these scripting procedures and functions is that you incorporate them into other applications, and programmatically perform the scripting if you need to.

But if you just want to create a script, that works too.

By default, it lists permissions for all logins, but you can also provide a list of the logins that you’re interested in, as a comma-delimited list, to the @LoginsToScript parameter.

2019-01-16

Need to learn to write T-SQL queries for SQL Server? Or need to become more confident?

Do you (or someone you know) need to learn to write T-SQL properly? Or perhaps you need to be more confident with joins, aggregations, CTEs, and more?

Our latest online on-demand course Writing Queries for SQL Server is now available, and at introductory pricing of just $95 USD.

It has detailed and comprehensive intro level coverage of the T-SQL language, and follows professional coding standards throughout. It’s also not just a set of videos; it includes extensive hands-on labs and quizzes to make sure the learning is great.

2019-01-15

SQL: Filtered indexes in SQL Server can be wonderful but be careful !

Back to the transaction table

Two weeks ago, I wrote about the issues with a large transaction table where only a handful of the rows were unfinalized, and that we would never use an index to find all the rows that were finalized. But we’d certainly want an index defined for the ones that weren’t. If you haven’t read that post, I’d suggest you do so before continuing to read. You’ll find it here.

2019-01-14