| A community of more than 1,600,000 database professionals and growing |
| | Short Names I started using computers a long time ago, and in the PC world, we were often limited to an 8 character name and a 3 character extension. Unix and MacOS allowed longer names, and many of us in DOS and Windows were jealous. Eventually Windows evolved, allowing long names, spaces, and really quite a bit of latitude in what you want to name a file. For example, try this and see what happens on your SQL Server: BACKUP DATABASE Sandbox TO DISK = 'Sandbox.thisisafullbackupthatIusetostartarestore' However, the three character extension still dominates, and many applications still use this. Microsoft has started to get away from this, as we have .docx, .xlsx, etc. Other vendors and software systems have started to expand names slightly. I was reading about the SQL Server Diagnostics Preview and noticed that the engineers will take a dump file (.dmp) as well as a mini dump (.mdmp) and a filtered dump (.hdmp). Now I know developers are lazy, and they don't like to type, but in these days of auto-completion and other tools, why are we limiting ourselves. Why wouldn't we use .minidump or .filtereddump as descriptive way of identifying the file? If we are no longer bound, why not include a better extension? I can't imagine that the filesystem for many tools would be stressed by longer names. I'm assuming that people still feel bound to using the shortest set of letters that they think are unique, but with the growth of software applications from many, many sources, why not just be more descriptive? Would you want to see better filenames? I know I would. Steve Jones from SQLServerCentral.comJoin the debate, and respond to today's editorial on the forums |
| The Voice of the DBA Podcast Listen to the MP3 Audio ( 2.7MB) podcast or subscribe to the feed at iTunes and Libsyn. The Voice of the DBA podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music. | |
|
|
| ADVERTISEMENT | | The industry standard for comparing and deploying SQL Server database schemas Trusted by 71% of Fortune 100 companies, SQL Compare is the fastest way to compare changes, and create and deploy error-free scripts in minutes. Plus you can easily find and fix errors caused by database differences. Download your free trial |
| | Database DevOps Demo Webinar Learn how to automate your database deployments alongside your app code in this free demo webinar. Register now |
|
|
|
| | | Daniel Calbimonte from SQLServerCentral.com There is a new utility to import data from SQL Server on premises or Azure SQL to Azure SQL Data Warehouse (ASDW) More » |
| Additional Articles from Database Journal Azure SQL Data Warehouse is Microsoft’s new enterprise-class, elastic petabyte-scale, data warehouse service that can scale according to organizational demands in just few minutes. In this installment, Arshad Ali covers the different ways to load data into SQL Data Warehouse. More » |
| Brian Kelley from SQLServerCentral Blogs Whenever I’m asked about creating a security model for an application or database, I tell folks to follow the Principle... More » |
| Grant Fritchey from SQLServerCentral Blogs I love Entity Framework. I also like (not love) nHibernate. That’s right, as a DBA and data professional, I’m telling... More » |
|
|
| | Today's Question (by Steve Jones): I've got a LineItem table iwth some quanties, prices, and discount percentages. The data looks like this: LineItemKey Qty Price DiscountPercentage ----------- ----------- ----------- ------------------ 1 10 5 0 2 25 8 5 3 100 11 10 I am trying to write a query that will give me the final price. SELECT LineItemKey, Qty, Price, DiscountPercentage, FinalCost = CAST((Qty * Price) - (DiscountPercentage / 100) AS DECIMAL(10, 2)) FROM dbo.LineItem; However, I get this result: LineItemKey Qty Price DiscountPercentage FinalCost ----------- ----------- ----------- ------------------ --------------------------------------- 1 10 5 0 50.00 2 25 8 5 200.00 3 100 11 10 1100.00 Why? |
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: T-SQL. We'd love to give you credit for your own question and answer. To submit a QOTD, simply log in to the Contribution Center. |
|
|
| |
ADVERTISEMENT | Automate your workload and manage more databases and instances with greater ease and efficiency by combining metadata-driven automation with powerful tools like PowerShell and SQL Server Agent. Automate your new instance-builds and use monitoring to drive ongoing automation, with the help of an inventory database and a management data warehouse. Get your copy from Amazon today. | | |
|
|
|
|
|
| Yesterday's Question of the Day |
| Yesterday's Question (by Thomas Franz): Which of the following SELECTs will return a line (select 9)? CREATE TABLE #test (id INT IDENTITY, some_stuff SQL_VARIANT); INSERT INTO #test (some_stuff) VALUES ('hey') INSERT INTO #test (some_stuff) VALUES (123) GO SET NOCOUNT ON; DECLARE @stuff SQL_VARIANT; /* 1*/ SET @stuff = 'hey'; SELECT 1, t.some_stuff FROM #test AS t WHERE t.some_stuff = @stuff /* 2*/ SET @stuff = '123'; SELECT 2, t.some_stuff FROM #test AS t WHERE t.some_stuff = @stuff /* 3*/ SET @stuff = 123 ; SELECT 3, t.some_stuff FROM #test AS t WHERE t.some_stuff = @stuff DECLARE @string VARCHAR(3); /* 4*/ SET @string = 'hey'; SELECT 4, t.some_stuff FROM #test AS t WHERE t.some_stuff = @string /* 5*/ SET @string = '123'; SELECT 5, t.some_stuff FROM #test AS t WHERE t.some_stuff = @string /* 6*/ SET @string = 123 ; SELECT 6, t.some_stuff FROM #test AS t WHERE t.some_stuff = @string /* 7*/ SET @string = 'hey'; SELECT 7, t.some_stuff FROM #test AS t WHERE t.some_stuff = cast(@string as sql_variant) /* 8*/ SET @string = '123'; SELECT 8, t.some_stuff FROM #test AS t WHERE t.some_stuff = cast(@string as sql_variant) /* 9*/ SET @string = 123 ; SELECT 9, t.some_stuff FROM #test AS t WHERE t.some_stuff = cast(@string as sql_variant) /*10*/ SET @string = 'hey'; SELECT 10, t.some_stuff FROM #test AS t WHERE CAST(t.some_stuff AS VARCHAR(3)) = @string /*11*/ SET @string = '123'; SELECT 11, t.some_stuff FROM #test AS t WHERE CAST(t.some_stuff AS VARCHAR(3)) = @string /*12*/ SET @string = 123 ; SELECT 12, t.some_stuff FROM #test AS t WHERE CAST(t.some_stuff AS VARCHAR(3)) = @string /*13*/ SET @stuff = 'hey'; SELECT 13, t.some_stuff FROM #test AS t WHERE CAST(t.some_stuff AS VARCHAR(3)) = @stuff /*14*/ SET @stuff = '123'; SELECT 14, t.some_stuff FROM #test AS t WHERE CAST(t.some_stuff AS VARCHAR(3)) = @stuff /*15*/ SET @stuff = 123 ; SELECT 15, t.some_stuff FROM #test AS t WHERE CAST(t.some_stuff AS VARCHAR(3)) = @stuff Answer: 1 3 4 7 10 11 12 13 14 Explanation: 1 - comparing a SQL_VARIANT containing a varchar ('hey') with another SQL_VARIANT containing a varchar ('hey) will be ok 2 - comparing a SQL_VARIANT containing an integer (123) with another SQL_VARIANT containing a varchar ('123') will fail 3 - comparing a SQL_VARIANT containing an integer (123) with another SQL_VARIANT containing a integer (123) will be ok 4 - comparing a SQL_VARIANT containing a varchar ('hey') with a VARCHAR(3) ('hey') will be ok 5 - comparing a SQL_VARIANT containing an integer (123) with a VARCHAR(3) ('123') will fail; neither the 123 on table side will not be converted implicit to varchar nor the '123' to integer 6 - comparing a SQL_VARIANT containing an integer (123) with a VARCHAR(3) (123) will fail too, since the integer 123 in the set statement will be converteted implicit into '123' (= same behavior as in answer 5) 7 - comparing a SQL_VARIANT containing a varchar ('hey') with an explicit converted SQL_VARIANT ('hey') will be ok 8 - comparing a SQL_VARIANT containing an integer (123) with varchar that was converted into SQL_VARIANT will fail, since the SQL_VARIANT contains the varchar '123' 9 - comparing a SQL_VARIANT containing an integer (123) with varchar that was converted into SQL_VARIANT will fail, since the SQL_VARIANT contains the varchar '123' (in the SET statement 123 was converted implicit into '123') 10 - comparing an explicit convertet varchar ('hey') with another varchar ('hey') will be ok 11 - comparing an explicit convertet varchar (123 -> '123') with another varchar ('123') will be ok 12 - comparing an explicit convertet varchar (123 -> '123') with another varchar ('123') will be ok (in the SET statement 123 was converted implicit into '123') 13 - comparing an explicit convertet varchar ('hey') with a SQL_VARIANT containing a varchar ('hey') will be ok (similar to answer 1) 14 - comparing an explicit convertet varchar (123 -> '123') with a SQL_VARIANT containing a varchar ('123') will be ok 15 - comparing an explicit convertet varchar (123 -> '123') with a SQL_VARIANT containing an integer (123) will fail (because of datatype mismatch) So when you have to handle SQL_VARIANTS (e.g. when working with sys.partition_range_values or sys.extended_properties), you have to ensure, that your variable is a SQL_VARIANT too and was filled with exact the same data type (answers 1 and 3). If this is not possible (since you do not know, if the integers where inserted as integer or as varchar) the best solution (imho) would be to explicit convert the SQL_VARIANT on the table side into a VARCHAR and compare it with a VARCHAR variable (answers 10 to 12). Remark: if you have an index on the SQL_VARIANT column, it would do an index scan (instead of seek) in this case, since the explicit convert will make it non-sargable. And of course you have to be careful when dealing with date or decimal datatypes (because of language settings). See click here » Discuss this question and answer on the forums |
|
|
| Database Pros Who Need Your Help |
| |
| 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 ©2017 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. Contact: webmaster@sqlservercentral.com |
|
|