Laden...
|
|
|
|
|
|
|
Question of the Day |
Today's question (by BTylerWhite): | |
Enumerate the Python List | |
I have the following code in Python: animals = ["cat", "dog", "elephant", "fox", "horse"] for index, animal in enumerate(animals, start=1): print(animal) print(index) What will be the result of printing the index variable after the loop completes? | |
Think you know the answer? Click here, and find out if you are right. |
Yesterday's Question of the Day (by Thom A) |
UTF8 and varchar lengths Consider you have below table with the following single value inserted: CREATE TABLE dbo.Test (S varchar(10) COLLATE Latin1_General_100_CI_AI_SC_UTF8); INSERT INTO dbo.Test (S) VALUES(N'?');What would be the resulting value returned from the below query? SELECT LEN(REPLICATE(S,10000)) AS ReplicatedLength FROM dbo.Test;Answer: 2666 Explanation: When declaring a length of a varchar (or nvarchar) the length parameter does not mean the total number of characters that can be stored, but the number of bytes. Both datatypes, without using MAX, can store up to 8,000 bytes; varchar stores the characters using single bytes while nvarchar double bytes (hence why it is capped at 4,000). When using a collation such as a UTF-8 collation, each characters stored in the string can use different amount of bytes. A character like "A" uses a single byte, "æ" uses 2 bytes, and "?" uses 3. As a maximum of 8,000 bytes then only 2,666 ? characters can be stored (with 2 bytes spare) in a varchar(8000). The reason that 10,000 characters are not stored is that REPLICATE will not implicitly convert a non-MAX datatype to a MAX. As a result the varchar's length property is "capped" at 8,000 bytes, and any characters that did not fit are truncated. Ref: char and varchar (Transact-SQL) REPLICATE (Transact-SQL) |
Database Pros Who Need Your Help |
Here's a few of the new posts today on the forums. To see more, visit the forums. |
SQL Server 2017 - Administration |
SQLServer Always-On and Bitlocker - Hi all, we have installed MSSQL 2017 with HA and Always on AGs on a Bitlocker-encrypted device. The latter is unencrypted on Bootup. The Service account for SQL is gMSA/AD-based. On server startup HA is brought up correctly but the SQL service is not started, hence it is configured for autostart. We have tried to […] |
Foglights - Hi, We are looking into the monitoring software foglights? any thoughts? |
SQL Server 2016 - Administration |
I cannot add a replica because of difference between instances - Hi There, Let me start with to say I am not a SQL administrator, but I would like to understand. I was busy with creating a sql cluster, so far so good. I created a database, created a backup, enabled Always on on every instance and whilst creating the availability group with the wizard I […] |
DQS LogOnWindowFailedToConnect - HI every one I'm running into problems in DQS I'll appreciate your advice, I tried several things but it is not running yet, we have the following error: SQL Server Data Quality Services -------------------------------------------------------------------------------- Message Id: LogOnWindowFailedToConnect Cannot connect to SERVER\INSTANCE. A .NET Framework error occurred during execution of user-defined routine or aggregate […] |
Queries - I am looking to see if there are any ways to improve the run time for select queries. Thoughts and ideas? I have select * from Table takes approx 40 mins. I know if I select required columns that might be little faster. But I need all columns for ETL. Select w/o data from tables […] |
Looking for good beginner Data Base Administration book for advanced developer - Hello SSC, I have been a SQL developer for close to 20 years. I know some DBA tasks like, backup restore, installation, granting access to users, etc. I have been trying to find a beginners book that can slowly walk me through all of the common administration tasks. I think like a developer, so topics […] |
SQL Server 2016 - Development and T-SQL |
sys.dm_db_index_physical_stats returning wrong object_ID in MSDB database - I'm running an index maintenance script on the MSDB database that loops through a table of indexes with fragmentation over 10% and right after applying Security Update for SQL Server 2016 Service Pack 1 GDR (KB4505219)(0000)(x64)(en), the script started generating an error at this point: ALTER INDEX [pk_MSdbms_map] ON [dbo].[ExternalMailQueue] REBUILD Msg 1914, Level 16, State […] |
Administration - SQL Server 2014 |
How to minimize the SQL Server log growth - In SQL Server 2014, I go to my database properties and tempdb's database properties and change the recovery model to simple to avoid the big log growth, I need to use select sql statment to query data from one table and then insert into another table, I know if I use where statement to perform […] |
Database backup/checkDB problems - Hi all, Got a very odd problem, and one I'm hoping has a solution. Running the following code: BACKUP DATABASE [MyDB] TO DISK = N'MyLocation\MyFileName.bak' WITH NOFORMAT, NOINIT, NAME = N'MyFileName', SKIP, REWIND, NOUNLOAD, STATS = 10 Results in the following exception: Msg 3203, Level 16, State 1, Line 1 Read on "MyLocation\MyDB.mdf" failed: 1117(The […] |
Development - SQL Server 2014 |
Do I need a trigger? - I want to test a condition during an insert or an update and only permit the insert or update if the condition is valid. The condition requires the evaluation of a value in multiple rows. My scenario is this; Multiple people can participate in the review of a submission. Only one person (at a time) […] |
How to improve the performance of insert?delete?update sql statement - as it was said in the title, which we should pay attention to when optimizing insert?delete?update sql statement? thanks The following points is what I know : don't use big transaction perform insert?delete and update sql statement by batch , and the numbers of batch is not too big if there is where statement, we'd […] |
SQL 2012 - General |
TDE Drama - My workplace uses a 3rd party key management system as an encryption provider for TDE. Most of the time, things go swimmingly, but apparently this morning I totally FUBARed one of our non-prod servers. I enabled the EKM provider stetting, created the Cryptopgraphic provider, created the initial credential, created a windows login that I added […] |
SQL Server 2019 - Administration |
Any way to use ReportServer in HA AND have two separate SSRS servers? - This is a little awkward to explain, but we have 2 SQL Server instances that have a Standard license. Based on this article, it is entirely possible to setup availability groups for the SSRS DB's (ReportServer and ReportServerTempDB) The author of that article clearly uses Enterprise since hes got two DBs in one availability group. […] |
General |
Tip for getting trifocals made for computer monitor use. - I want to share with those of you advancing in years something I learned over 40 years ago regarding trifocal lenses for using with computer monitors. I was in my 30's when I developed the need for trifocal lenses. When I got my first pair I soon discovered that the 'standard' narrow band of focus […] |
Analysis Services |
Import a PBIX file into Azure Analysis Services - I want to import a Power BI PBIX file into Azure Analysis Services. I don't see any recent information on how to do that. Is it possible? If so, how? |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Laden...
Laden...
© 2024