Help: SQL Server

Sharing my knowlege about SQL Server Troubleshooting Skills

  • Blog Stats

    • 2,158,203 hits
  • Select GETDATE()

    April 2026
    M T W T F S S
     12345
    6789101112
    13141516171819
    20212223242526
    27282930  

Archive for 2014

A-Z of In-Memory OLTP: Online gaming casinos can handle more data per second

Posted by blakhani on September 2, 2014


I have been working with this new feature since its release and I am always amazed to see how it can change the world. Running an online casino is no joke. Not only do providers need to make sure that their customers are protected from data theft, but they also need to be certain that servers are always stable especially during peak hours. An overloaded server disconnects a player from the game, and providers can’t afford that to happen all the time. Competition is tight, so online casinos need to keep their customers happy.

Cryptologic, the world’s first casino brand to offer gaming services to the public in 1996 through their brand InterCasino, said that in the past, they used to only handle 14,000 people on one server. But today, according to the data by Statistica, online casino is now a 39.5 billion dollar industry that’s played by millions of people around the world. A stable server today should at least be able to handle a quarter of a million requests per second.

A case study by Microsoft revealed how a casino gaming site can scale up to 250,000 requests per second, and improve the gaming experience of players through an In-Memory Online Transaction Processing (OLTP) solution in Microsoft SQL Server 2014. According to the casino gaming site, it used to be able to handle only 30,000 batch requests per second. But with the upgraded system, not only can it handle 250,000 requests per second, but also provide their players a smooth gaming experience.

As I explained in first part of series SQL Server that uses a main memory optimization and no-locking/no-latching concurrency control in order to remove the jam that’s causing the scaling up. Using the OLTP in the feature has also improved the response time to 2-3 milliseconds, which is way faster than the old system that the online casino gaming site uses that needed a 50 millisecond delay.

Every second counts in a casino game – May it be poker or slot machine. By integrating an in-memory OLTP in Microsoft’s SQL server 2014, casino providers will be able to provide a faster and more stable gaming experience to their customers. Read more about Microsoft’s case study here

  • Cheers,
  • Balmukund Lakhani
  • Twitter @blakhani
  • Author: SQL Server 2012 AlwaysOnPaperback, Kindle
  • Posted in A - Z Series, In Memory OLTP, In-Memory OLTP | Tagged: , , | 5 Comments »

    Troubleshooting : Error – Incorrect syntax near ‘GO’

    Posted by blakhani on August 28, 2014


    Sometimes we are very comfortable and used to with certain things that if they change, we become nervous and uneasy. I have a lovely daughter and she always greets me when I come back home from office. That one “hello” takes away all my worries and I feel alive. Yesterday she didn’t do that and I was worried. I checked with my wife and she told that there was a mild fever and her mood is little different today. That made me little nervous.

    Same feeling happened when I saw below in management studio of my colleague:

    Msg 102, Level 15, State 1, Line 2

    Incorrect syntax near ‘GO’.

    image

     

    and management studio intellisense feature was also complaining about syntax. “Incorrect syntax near ‘End Of File’. Expecting ‘=’. As per documentation “GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor”

    I went to Tools > Option in Management studio and found that there was a customization done on batch separator. SSMS> Tools > Options >Query Execution > SQL Server > General > Batch Separator.

    Which means if I run with “come” it should work and as expected.

    image

    Perfect! This mystery is solved now. This made me think that can we customize SQLCMD as well. If we look into help of SQLCMD we can see parameter -c cmdend

    image

    Here is the usage of parameter –c . I have used hello as command end parameter and hello works same as go in true sense.

    image

    I hope this clears some confusion about batch separator.

    If you are getting this error while using ExecuteNonQuery in .net program and running script then refer http://blogs.msdn.com/b/onoj/archive/2008/02/26/incorrect-syntax-near-go-sqlcommand-executenonquery.aspx which has a workaround.

    Hope this helps!

  • Cheers,
  • Balmukund Lakhani
  • Twitter @blakhani
  • Author: SQL Server 2012 AlwaysOnPaperback, Kindle
  • Posted in SSMS, Troubleshooting | Tagged: , , , , , , | 2 Comments »

    Help : Getting error – Cannot resolve the collation conflict

    Posted by blakhani on August 26, 2014


    Recently someone posted on MSDN forum about collation related error which I have seen multiple times. Today I am taking time to write notes about that. Here is the famous collation conflict error which every DBA would encounter at least once in their career.

    Msg 468, Level 16, State 9, Line 29

    Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

    Let’s understand the error first. There are two collation in the error message. If you read in a flick they look similar but they are not. First one has CS (stands for case sensitive) and second one has CI (stands for case insensitive). From the message it’s clear that SQL can’t convert value implicitly between these two collations. Next action would be to you capture a profiler trace or some other troubleshooting technique to identify offending query. In other words, we get this error when queries use two or more columns with different collations for join and comparison purposes. So there could be two possibilities of getting this error message:

    1. Columns are in two different databases that have a different default collation.
    2. Columns are in same database that have collation explicitly specified as different.

    In most of the cases, this error has been caused when database was moved from one server to another server and this falls under first category. Here is the quick script to get same error.

     

    CREATE DATABASE [CaseSensitiveCollation]
     COLLATE SQL_Latin1_General_CP1_CS_AS
    go
    Use [CaseSensitiveCollation]
    go
    Create table MyTableInCaseSensitiveDatabase (vc varchar(100))
    go
    insert into MyTableInCaseSensitiveDatabase
    values ('sysobjects')
    go
    SELECT
    * FROM master.sys.objects a INNER JOIN CaseSensitiveCollation.dbo.MyTableInCaseSensitiveDatabase b ON a.NAME = b.vc

    Here is the screenshot.

     

    image

     

    The collation of master database is SQL_Latin1_General_CP1_CI_AS and for column vc in the table its different and hence the error.  Now, how do you resolve this error? We have multiple options.

     

    • Help SQL Server in identifying which column we want to convert to different collation.
    SELECT * 
    FROM   master.sys.objects a 
           INNER JOIN CaseSensitiveCollation.dbo.MyTableInCaseSensitiveDatabase b 
                   ON a.name = b.vc   collate SQL_Latin1_General_CP1_CI_AS
    • If this is due to restore of the database from different server then check server collation of source server. In this situation, we might have to rebuild the target server to match the source server for the collation. This is as good as reinstalling SQL Server.
    • If we are getting this error for a database which is created as a part of a product installation then we should review the product documentation for details on supported collations.

    I have seen few DBA suggesting to change database collation. It is important to understand that column collation is specified during creation of table. We can find that using below

    image

    Even if we alter the database the collation of already created table would NOT change. Only way to change the collation of existing tables is

    • Move the data to a new table with new collation.
    • Get the script of the table and create same index, stats etc. on new tables.
    • Drop the old table
    • Rename new table as old table. 

    If error is due to temporary tables created in tempdb database then you need to give a thought to contained database feature. Other thing Another option would be to provide the column level collation while creating table as below.

    CREATE TABLE #SQLServerHelp
       (iPK int PRIMARY KEY,
        nCol nchar COLLATE SQL_Latin1_General_CP1_CS_AS
       );
    

    Here are other error which you might get.

    • Cannot resolve collation conflict between "%ls" and "%ls" in %ls operator for %ls operation.
    • Collation conflict caused by collate clauses with different collation ‘%.*ls’ and ‘%.*ls’.
    • Cannot resolve collation conflict between "%ls" and "%ls" in %ls operator occurring in %ls statement column %d.
    • Implicit conversion of %ls value to %ls cannot be performed because the resulting collation is unresolved due to collation conflict between "%ls" and "%ls" in %ls operator.
    • Implicit conversion of %ls value to %ls cannot be performed because the collation of the value is unresolved due to a collation conflict between "%ls" and "%ls" in %ls operator.
    • Cannot resolve the collation conflict between "%.*ls" and "%.*ls" in the %ls operation.

    Hope this would help you in troubleshooting and fixing collation errors.

  • Cheers,
  • Balmukund Lakhani
  • Twitter @blakhani
  • Author: SQL Server 2012 AlwaysOnPaperback, Kindle
  • Posted in Error, Troubleshooting | Tagged: , , , , | 1 Comment »