| A community of more than 1,600,000 database professionals and growing |
| | Do you use custom schemas? Today we have a guest editorial as Steve is out of the office. I assume we are all familiar with dbo. in front of table names and all the other database objects. This is the default schema in SQL server. I would guess many of you use custom schemas with your systems, but perhaps some of you do not. A custom schema will put a different prefix in front of your database objects. I think custom schemas are incredibly useful and should be used as much as possible. One benefit of a custom schema is the way it groups object and tables together. Often we have many different systems all living on the same database. In this case segregating systems by unique schemas can really help with organization of your database objects. It becomes very clear which tables, stored procedures, functions, views, etc. belong to which system. It can really cut down on the confusion we sometimes run into wondering which systems use which objects. Even if you only have one system on your database it makes sense to have a custom schema because of security. Granting security is one of my favorite things to do for a system with a custom schema that forces all database access via stored procedures. When an AD group needs to access the system all I have to do is: GRANT EXECUTE ON SCHEMA :: CustomSchemaName TO ADGroupName I don’t have to give datareader or datawriter access to anyone. I don’t have to give DBO role membership, (I would not suggest that anyway). I just grant execute rights on the schema to the AD Group. To me it feels like the way SQL server security was meant to be done. Sure there can be some downsides. You can’t just put table names in your queries. You always have to prefix your tables and objects with the correct schema name. Of course, it can be argued that you should be doing that anyway, even if your schema is dbo. You also need to be careful to decorate your stored procs, functions etc. with the correct custom schema when creating them. Another issue is if you don’t name your schemas well, it can cause some confusion. I have worked at companies where a custom schema name matched an existing database name. It was very annoying. I would not suggest doing that. Also, it can be tempting to use an acronym for short name, but in my experience it is more helpful to have a custom schema name that is readable and meaningful to others. For example, it probably makes more sense to have PriceListObj. instead of PLO. Steve Jones recently wrote an article on the importance of properly setting the owner of a custom schema. I think he makes some good points that are worth reading. If you missed it, you can see his article here: Being Careful with Schema Ownership In the end, because of the organizational and potential security benefits I think custom schemas are a great resource for DBA and database developers. Share your experience with custom schemas. If you don’t use them explain why not? Ben Kubicek from SQLServerCentral.comJoin the debate, and respond to today's editorial on the forums |
|
| ADVERTISEMENT | | Become a more efficient SQL developer with SQL Prompt Learn how to write SQL faster and more efficiently with these exclusive short videos from Data Platform MVPs and SQL Server experts. With SQL Prompt you can strip out the repetition of coding and write SQL 50% faster. Check out the tips |
| | Redgate University Self-paced online training courses with easy to follow classes on getting started, exploring advanced features, and making the most of Redgate products. Learn the fundamentals, best practices, and top tips from the experts - Redgate’s Microsoft Data Platform MVPs and engineers. Start Learning |
|
|
|
| | | Toby Ovod-Everett from SQLServerCentral.com Demonstration of the T-SQL Decommenter removing comments from a sample T-SQL batch. More » |
| Additional Articles from SimpleTalk Database administrators are typically responsible for the security and availability of financial data. In this article, Robert Sheldon discusses SOX, passed in 2002, that governs financial data of publicly traded companies in the US. More » |
| Database development practices are more integral than ever to DevOps success. How are we saving time, automating processes, deploying more frequently, all whilst keeping business critical data secure? Take part in the survey for an advanced copy of the research report, and a chance to win a $250 Amazon voucher. More » |
| Bert Wagner from SQLServerCentral Blogs This post is a response to this month’s T-SQL Tuesday #108 prompt by Malathi Mahadevan. T-SQL Tuesday is a way... More » |
| david.fowler 42596 from SQLServerCentral Blogs So, this month’s T-SQL Tuesday topic is to think about a non-SQL Server technology that we want to learn. For me,... More » |
|
|
| | Today's Question (by Steve Jones): In SQL Server 2016, when deploying an Availability Group on Windows, a Windows Server Failover Cluster (WSFC) is needed. |
Think you know the answer? Click here, and find out if you are right. We keep track of your score to give you bragging rights against your peers. This question is worth 1 point in this category: Availability Group (AG). We'd love to give you credit for your own question and answer. To submit a QOTD, simply log in to the Contribution Center. |
|
|
| |
| Yesterday's Question of the Day |
| Yesterday's Question (by Steve Jones): I have a data frame in R v3.5 defined like this: > df= read_csv('https://data.ny.gov/api/views/5xaw-6ayf/rows.csv?accessType=DOWNLOAD', col_names = TRUE) I want to sample the first few rows to get an idea of columns. I run this: > head(df) How many rows are returned? Answer: 6 Explanation: The default number of rows for head() is 6. Ref: head, tail - click here » Discuss this question and answer on the forums |
|
|
| | Timothy Harms from SQLServerCentral.com Set the variable values, entering server name, database name, table name open query and debug, shown below.. @ServerNVARCHAR(1000) = ''/*can be blank for non openquery*/ @DatabaseNVARCHAR(1000) = ''/*cannot be blank*/ @TableName NVARCHAR(1000) = ''/*cannot be blank*/ @OpenQuery BIT= 0/*1 will use open query, 0 will not*/ @Debug BIT = 0 /*1 with Print @sql, 0 will execute @sql*/ and execute. More » |
|
|
| Database Pros Who Need Your Help |
| Here's a few of the new posts today on the forums. To see more, visit the forums. TDE question - I have a TDE Question. After I restore a database that is TDE enabled from one server to another server, does... How to encrypt all stored procedure, functions and views in sql server - Hi, How to encrypt all stored procedure, functions and views in sql server. Please advise best method, is available any tool for... Select Into as Number and Date rather than Text - Guys, how do i ensure the below date columns 'Updated', 'ContDate', 'Complete', 'FollDate' insert as dates not text and that... Query first 2 results based on age and description - Guys, Is there a way to do the following. Temp data and expected results included: The oldest 2 results based on... DT_BYTE to DT_DBDATE - I've got an SSIS project pulling data from a MySQL database into SQL Server. One of the date values in the... Trigger on saving a stored procedure or function. - We would like the act of saving a T-SQL procedure or function to automatically append the name of the programmer... Compare top 2 transactions from 12 months from the current transaction date - Importing from XML to SQL 2014 - This is my 4th day on SQL so I am a newbie. I created a query to import from an... Creating a Stored Procedure with Loop and If statement into a new table - Hi Guys, Can anybody help? Encryption and data length limitations - I'm having an issue in encrypting large documents. I know that previous editions ENCRYPTBYKEY had a maximum size of 8,000... How do I compare values in two columns based on a static date - So, I have been asked to provide a way to compare daily data that comes in to a given date.... Pass SSIS parameter into Agent Job - Hi The problem: I am calling a stored proc from VBA which executes a stored proc. The stored proc triggers an... SQL Auditing - I’ve been looking into solutions for change tracking of our SQL data. Any idea about CDC? Any thoughts on that... Error converting data type DBTYPE_DBDATE to date - Every night we run an import from an IBM Informix DB to our server via a Linked Server. A few... Insert with null - Hi I have a table called Remote_Item with some records like How to bulk SPECIFC data from a DB respecting ALL CONSTRAINTS! - Hi all, my company has a centralized database that contains data that belongs to many different locations. I have now... Windows Updates cause applications to disconnect from SQL Server - I'm not sure if this is the right forum to post this but: Our production server has been having a problem... how to find the lowest usage of a database - Hi Guys How do we find the lowest usage of a database ? I need to find the best time to ... How do you change the Text Legend to BOLD just for the total in the SRSS report? - In my Series Group, I have the Label with the following expression: =(Fields!School.Value) & (COUNT(Fields!School.Value, "Chart3_SeriesGroup")) want to make the COUNT part appear... SELECT TOP 1 on Primary Key? - I have a table (let's call it TableA) with a primary key defined (let's say the column is called ColumnPrimary).... |
|
| This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. | This newsletter was sent to you because you signed up at SQLServerCentral.com. Feel free to forward this to any colleagues that you think might be interested. If you have received this email from a colleague, you can register to receive it here. | This transmission is ©2018 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. Contact: webmaster@sqlservercentral.com |
|
|