Puzzle: TRY_CAST in Azure SQL, TRY_CONVERT in SS 2012?

For a while I thought Azure SQL T-SQL is a subset of SQL Server 2012 T-SQL. Not so.... It has its own individuality!
Related blog:
http://raresql.com/category/sql-server-2012/built-in-functions/conversion-function/
Kalman Toth Database & OLAP Architect
Paperback / Kindle: Windows Azure SQL Database Programming & Design

Cancel question. TRY_CAST() works in SQL Server 2012 and SQL Server 2014.
SET DATEFORMAT dmy;
SELECT TRY_CAST('12/31/2010' AS datetime2) AS Result;
GO
-- NULL
SET DATEFORMAT mdy;
SELECT TRY_CAST('12/31/2010' AS datetime2) AS Result;
GO
-- 2010-12-31 00:00:00.0000000
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Similar Messages

  • Azure Sql DB Export to Storage Container fails with "An error occurred while sending the request"

    I've built a new VM from which I'm running PowerShell scripts to backup my databases.  It had worked before on an old server for several months, and worked once on the new server, then I upgraded my Azure PowerShell cmdlets, and haven't been able to
    get it to work again.  The new version is 0.8.10.1.
    Below is my source code, with sensitive stuff replaced with ?'s.  When I display the $stctx and $dbctx, they seem to have reasonable values.  I added the IP address of the server as an exception to the db firewall, and I've installed SQL Server
    Mangement Studio and verified that I can connect to the database.  I have a feeling there's something simple I've overlooked.
    Here's are both error messages:
    Start-AzureSqlDatabaseExport : An error occurred while sending the request.
    At C:\Users\Public\PublicCmds\test.ps1:29 char:1
    + Start-AzureSqlDatabaseExport -SqlConnectionContext $dbctx -StorageContext $stctx ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Start-AzureSqlDatabaseExport], HttpRequestException
        + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.StartAzureSqlDatabaseExport
    Start-AzureSqlDatabaseExport : Error while copying content to a stream.
    At C:\Users\Public\PublicCmds\test.ps1:29 char:1
    + Start-AzureSqlDatabaseExport -SqlConnectionContext $dbctx -StorageContext $stctx ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Start-AzureSqlDatabaseExport], HttpRequestException
        + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.StartAzureSqlDatabaseExport
    Here is the source code:
    param($dbname)
    if ($dbname -eq $null) {
    write-host "Database code must be specified"
    return
    $password = "????"| ConvertTo-SecureString -asPlainText -Force
    $servercredential = new-object System.Management.Automation.PSCredential("????", $password) 
    $dbsize = 1
    $dbrestorewait = 10
    $dbserver = "????"
    $stacct = $dbname
    $stkey = "????"
    $stctx = New-AzureStorageContext -StorageAccountName $stacct -StorageAccountKey $stkey
    $dbctx = New-AzureSqlDatabaseServerContext -ServerName $dbserver -Credential $servercredential 
    $dt = Get-Date
    $timestamp = "_" + $dt.Year + "-" + ("{0:D2}" -f $dt.Month) + "-" + ("{0:D2}" -f $dt.Day) + "-" + ("{0:D2}" -f $dt.Hour) + ("{0:D2}" -f $dt.Minute)
    $bkupname = $dbname + $timestamp + ".bacpac"
    write-host "db context"
    $dbctx
    write-host "storage context"
    $stctx
    write-host "Backup $dbname to $bkupname"
    Start-AzureSqlDatabaseExport -SqlConnectionContext $dbctx -StorageContext $stctx -StorageContainerName databasebackup -DatabaseName $dbname -BlobName $bkupname

    Hi Brad,
    Mentioned script, with appropriate values, works on my system.
    I'm able to export an Azure SQL database to blob storage. Am using version 0.8.10.1 of cmdlets, so this the same version mentioned in this problem description.
    Can you please try using Add-AzureAccount and check if that helps. This is indicated in a different third-party blog.
    http://answers.flyppdevportal.com/categories/azure/azuretroubleshooting.aspx?ID=8aee89fe-430e-45fe-af54-7c8ed3ac60e1%29."http://answers.flyppdevportal.com/categories/azure/azuretroubleshooting.aspx?ID=8aee89fe-430e-45fe-af54-7c8ed3ac60e1
    Does it work from a different machine with newly downloaded credentials.
    Does it work for a newly created database (so minimal database size).
    If above do not work, we may require additional details like RequestID, StorageAccountName, ServerName so an MS ticket may be more appropriate.
    Girish Prajwal

  • Database Initialiser does not create azure sql database

    I have a WPF application In the OnStartup in the app.cs I set the Database initializer and forced the context the initialise my database:
    Debug.WriteLine("Setting Initializer");
    Database.SetInitializer<MyContext>(new MyDatabaseInitializer());
    Debug.WriteLine("Declaring new context");
    using (MyContext c = new MyContext("MyContext"))
    Debug.WriteLine("Force the initialization");
    c.Database.Initialize(true);
    Debug.WriteLine("Done!");
    I created a sql database in the management portal of the azure.
    Copied the connectionstring it provided for ADO.net.
    But my database is not created.
    I also added a firewall rule but nothing happens. I Have no clue what to do.
    Can anybody please help me with this?
    If you need more information please ask i really have to get this sorted out.
    Thanks in advance!

    Hi Turkstra,
    I have tried to use EF to create Azure SQL database, it works as expect, the database 'jambordbcreate' appear in my SQL Azure, below is the detailed codes.
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace CodeFirst
    class Program
    static void Main(string[] args)
    Database.SetInitializer(
    new CreateDatabaseIfNotExists<SchContext>());
    using (var db = new SchContext("Server=tcp:****.database.windows.net,1433;Database=jambordbcreate;User ID=vote@***;Password=***;Trusted_Connection=False;Encrypt=True;Connection Timeout=30"))
    string name = "jambor";
    var student=new Student(){Name=name, ID="1a"};
    db.Students.Add(student);
    db.SaveChanges();
    db.Database.Initialize(true);
    public class Student
    public string ID { get; set; }
    public string Name { get; set; }
    public string age { get; set; }
    public string sex { get; set; }
    public class School
    public string ID { get; set; }
    public string Name { get; set; }
    public virtual List<Student> Students { get; set; }
    public class SchContext : DbContext
    public SchContext(string connection):base(connection)
    public DbSet<Student> Students { get; set; }
    public DbSet<School> Schools { get; set; }
    I suggest  you check your SQL connection, after run your code, please refresh azure portal to see whether your database is exist. Hope this give you some help.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Azure remote App with Azure SQL Backend

    Hi, If I had an application which utilised a SQL backend could I host the front end in Azure remote app and the backend on an Azure SQL database or would I need to use IAAS to provide the backend?
    Many thanks
    James 

    Hi James,
    If the application is designed to be compatible with Azure SQL Database then yes, you can use Azure RemoteApp for the frontend and Azure SQL Database for the backend.  If the application is not compatible with Azure SQL Database then you would
    need to use SQL Server running in an IaaS VM, or SQL Server running in an on-premises VM.  The IaaS VM or SQL Database should be in the same Azure region as the RemoteApp collection in order to minimize latency.
    For example, say you have an internally-developed application that uses SQL Server 2012 as its backend database.  Before you would be able to use Azure SQL Database you would first need to migrate the database to Azure SQL Database and make any changes
    necessary to the application and/or database for compatibility.  The SQL Database Migration Wizard is helpful for this process.
    -TP

  • Can No Longer Connect to Azure SQL Databases

    As of this morning, I am no longer to connect to any of my Azure SQL databases by any (apparent) means. I checked the configuration in the azure portal and my IP address is listed as an allowed IP, however:
    I am unable to connect via SQL Server Management Studio
    My request times out when attempting to visit https://{server_name}.database.windows.net
    What might have caused this?

    Hi ,
    Thanks for posting here.
    To resolve the issue you can try the following steps (in that order):
                    Check the application’s connection string to make sure that it is correctly configured. For example, make sure that the connection string specifies the correct port
    (1433) and the fully qualified server name.                
    Note You can follow these steps to obtain the connection string from the Azure Management Portal:                  
                          Log on to the
    Azure Management Portal.                    
                          In the left navigation pane, click
    SQL Databases.                    
                          Select your Azure SQL Database server.                    
                          Click
    Dashboard.                    
                          On the right side, go to the
    quick glance section, and then click Show connection strings.                    
                    Make sure that TCP IP is enabled as a client protocol on the application server. For more information on how to do this, see
    Configure client protocols. On application servers where you do not have SQL Server tools installed, you can check this by running cliconfg.exe (SQL Server Client Network Utility).              
                    Test the connectivity between the application server and the Azure SQL database by using a UDL file, ping, and telnet. For more information about how to do this,
    see
    Azure SQL Database connectivity troubleshooting guide and
    Troubleshooting SQL Server connectivity issues.                
    Note As a troubleshooting step, you can also try to test the connectivity on a different client computer.                
                    Try increasing the connection
    timeout. Microsoft recommends using a connection timeout of at least 30 seconds.              
                    As a best practice ensure retry logic is in place. For more information about the retry logic, see
    Azure SQL Database best practices to prevent request denials or connection termination.              
                  If the previous steps do not resolve your problem, follow these steps to collect more data and contact support:              
                      If your application is a cloud service, enable the logging. This step returns a UTC time stamp of the failure. Additionally, SQL Azure returns the tracing
    ID.
    Microsoft Customer Support Services can use this information.                
                      For more information about how to enable the logging, see
    how to enable diagnostic logging for Azure Web sites and Developing SQL Database Applications section in
    Azure SQL Database Development Considerations.
    Please write back with the exact Error message/ Error Code if this doesn't help.
    Regards,
    Shirisha Paderu.

  • Contained Database Users are now available in Azure SQL Database Update preview

    Contained Database Users should be of particular help for people migrating to Azure SQL Database. At the moment, this is a preview release but you can start testing. Here is the announcement of the
    preview with links to more information.
    New SQL Database public preview with new Standard-tier performance level
    Previously announced in November 2014 and now available for customers to try, the
    new
    public preview of SQL Database improves the compatibility of SQL Server applications for Azure SQL Database. Details of this preview are available on the
    SQL
    Database documentation webpage, including the following key enhancements: easier management of large databases to support heavier workloads with parallel queries
    and online indexing, support for programmability functions like CLR and XML index to support more robust application design, improved monitoring and troubleshooting with XEvents and 100 new Dynamic Management Views (DMV), and more performance in the Premium
    tier.
    To try this preview, please sign up via the Preview
    features webpage. Only SQL Database servers with a mix of one or more Basic, Standard, or Premium (not Web or Business) databases are compatible and eligible to
    upgrade to the preview. Please note that any move of an existing Basic, Standard, or Premium database into this preview is irreversible; we recommend that you create a database copy or leverage test databases on any server enrolled in this preview.
    A new Standard-tier performance level, S3, is also available in this preview which gives you more pricing flexibility between Standard and Premium. S3 will deliver 100 Database Throughput Units (DTU) and all the features available in the Standard tier. Please
    note that S3 will appear on your bill as a multiple of S2 until further notice.
    For more information, please visit the SQL
    Database webpage and the
    Microsoft
    Azure Blog. For a comprehensive look at pricing, please visit the
    SQL
    Database pricing webpage.
    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty

    Hello Rick
    That is great, one thing I'd like to ask, does it support SSMS,SSDT?
    No sign of that yet, that I’ve seen.....
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Which is better for performance Azure SQL Database or SQL Server in Azure VM?

    Hi,
    We are building an ASP.NET app that will be running on Microsoft Cloud which I think is the new name for Windows Azure. We're expecting this app to have many simultaneous users and want to make sure that we provide excellent performance to end users.
    Here are our main concerns/desires:
    Performance is paramount. Fast response times are very very important
    We want to have as little to do with platform maintenance as possible e.g. managing OS or SQL Server updates, etc.
    We are trying to use "out-of-the-box" standard features.
    With that said, which option would give us the best possible database performance: a SQL Server instance running in a VM on Azure or SQL Server Database as a fully managed service?
    Thanks, Sam

    hello,
    SQL Database using shared resources on the Microsft data centre. Microsoft balance the resource usage of SQL Database so that no one application continuously dominates any resource.You can try the 
    Premium Preview
    for Windows Azure SQL Database which offers better performance by guaranteeing a fixed amount of dedicated resources for a database.
    If you using SQL Server instance running in a VM, you control the operating system and database configuration. And the
    performance of the database depends on many factors such as the size of a virtual machine, and the configuration of the data disks.
    Reference:
    Choosing between SQL Server in Windows Azure VM & Windows Azure SQL Database
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Add SQL reporting services to get Azure sql db data

    Dear all,
    I have read recently that SQL server reporting services as been remmoved from Azure services. I have a SQL server database on azure which collect different type of data which are collected from a web admin portal by my users.
    I have a strong need to bring to that admin web portal a flexible reporting solution for my users to monitor collected data.
    Of course I can bring dash board to web application but often it is painful to change web app when a user want different type of report.
    What could be the way now to use online reporting service in orde to bring online report for my user of my sql azure database ?
    regards
    serge

    Hi serge,
    Based on my understanding, you want to use SQL Azure database to design the report, right?
    As you mentioned,
    Azure SQL Reporting is officially discontinued, so that we can’t design reports with Azure SQL Reporting. However, only the Azure cloud implementation of SQL Reporting is discontinued. All other forms of Reporting Services technology are unaffected. In
    Reporting services, it’s supported connect to SQL Azure database. So in your scenario, you can connect to the SQL Azure database to design the report. For more information, please refer to this article:
    How to connect to SQL Azure using SQL Server Reporting Services 2008 R2.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • Sql Server Web Edition Reporting Services errors when trying to connect to Windows Azure SQL

    I am using a preconfigured image from the Azure VM Gallery to create a VM.
    --> Sql Server 2012 SP1 Web running under Windows Server 2008 R2
    After configuring Reporting Services I get the following error when trying to run a report that connects to my Azure SQL db.
    An error has occurred during report processing. (rsProcessingAborted)
    An attempt has been made to use a data extension 'SQLAZURE' that is either not registered for this report server or is not supported in this edition of Reporting Services. (rsDataExtensionNotFound)
    On the VM using SSMS I can connect to the Azure SQL db.  On the VM in Report Builder when I define a connection I get a similar error to the one above when I test that connection.  I am using Microsoft Azure SQL as the data source type. 
    Interestingly in Report Builder, if I proceed past the connection definition, I can see the tables from my Azure SQL db in the dataset definition page.
    One more note.  If I use a different image from the Gallery (Sql Server 2012 Standard SP1 on Windows Server 2012) my report builder connection works and the reports run fine.  I believe that the Azure documentation says that Sql Server Web edition
    is an acceptable choice for the SSRS on VM for reporting.
    Any thoughts or suggestions?
    Thanks -- Tom Reilly

    Hello,
    A VM with SQL Server 2008 R2 or 2012 supports all Reporting Services features, including all supported data sources, customization and extensibility, and scheduled report execution and delivery.
    Did you run the report in Report Manager,or preview the report in Report Builder? Which version of the Report Builder you installed in the Windows Azure VM? SQL Reporting does not support reports created from Report Builder 1.0 or 2.0. You can create reports
    using Report Builder 3.0 and then upload the reports.
    What's more, please also check the database source credential of the report.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here.
    Fanny Liu
    TechNet Community Support

  • Cannot Connect to Azure SQL Database in Visual Studio 2013

    Beyond Frustrated here.
    I am trying to connect to an Azure SQL database - it has been created, has tables etc. I am trying to create a new Data Connection from within Visual Studio 2013, latest release for VS and Azure. I continue to receive the following error:
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
    (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
    I have ensured that TCP is allowed and above Named Pipes in the Configuration Manager. The associated IP address is allowed on Azure Firewall. Certificate has been added to VS etc. But still no connection. I can see the database in the Azure section in Server
    Explorer, but cannot add a Data Connection. What is equally as frustrating is I have a MacBook Pro running Win 7 sitting right next to my office computer and it can access Azure fine, not problems.
    If anyone has any other ideas on how I might be able to solve this I would love to hear them. Thanks in advance.
    Jeff

    Hi,
     The Error message "   A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is
    configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53) "
    The issue comes up mainly because the application is not able to connect to the server.
    To resolve this issue, try the following steps (in that order):
     Make sure that TCP IP is enabled as a client protocol on the application server. For more information on how to do this, see
    Configure client protocols. On application servers where you do not have SQL Server tools installed, you can check this by running cliconfg.exe (SQL Server Client Network Utility).              
     2.  Check the application’s connection string to make sure that it is correctly configured. For example, make sure that the connection string specifies the correct port (1433) and the fully qualified server name.                
    Note You can follow these steps to obtain the connection string from the Azure Management Portal:                  
                          Log on to the
    Azure Management Portal.                    
                          In the left navigation pane, click
    SQL Databases.                    
                          Select your Azure SQL Database server.                    
                          Click
    Dashboard.                    
                          On the right side, go to the
    quick glance section, and then click Show connection strings.                    
    Test the connectivity between the application server and the Azure SQL database by using a UDL file, ping, and telnet. For more information about how to do this, see
    Azure SQL Database connectivity troubleshooting guide and
    Troubleshooting SQL Server connectivity issues.                
    Note As a troubleshooting step, you can also try to test the connectivity on a different client computer.                
    Try increasing the connection timeout. Microsoft recommends using a connection timeout of at least 30 seconds.              
    As a best practice ensure retry logic is in place. For more information about the retry logic, see
    Azure SQL Database best practices to prevent request denials or connection termination.              
          If these  steps do not resolve your problem, follow the below steps to collect more data and contact support:              
       If your application is a cloud service, enable the logging. This step returns a UTC time stamp of the failure. Additionally, SQL Azure returns the tracing ID.
    Microsoft Customer Support Services can use this information.                   
       For more information about how to enable the logging, see
    how to enable diagnostic logging for Azure Web sites and Developing SQL Database Applications section in
    Azure SQL Database Development Considerations.                
      Check out
    the list of best practices for Connecting to Windows Azure SQL Database.
    Regards,
    Shirisha Paderu.

  • Connecting to an Azure SQL Database from VB6

    We have an old Application that is accessing a database located on a client site. We currently access this database using ADO and SQL Authentication. Would it be possible to migrate to Azure SQL Server and connect to it from the VB6 Application by just changing
    the connection string?

    Yes, but you have to make sure that you are not using any features that SQL Azure doesn't support. And make sure that the SQL Azure server address is open for connection from outside. You also need to be concerned about data security.
    Frank

  • Consistently getting "The wait operation timed out" when connecting to Azure SQL Database from a virtual instance...

    I have a web app that is backed by a an Azure SQL Database. The problem is that I had multiple issues when connecting to the database mainly when trying to establish a connection, or timeouts. This is the log I just encountered when trying to use the web
    app.
    [Win32Exception (0x80004005): The wait operation timed out]
    [SqlException (0x80131904): Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=21970; handshake=1; ]
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +671
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1012
    System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6712291
    System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +152
    System.Data.SqlClient.SqlConnection.Open() +229
    System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +102

    Hi Affar2k,
    According to your description, we need to verify if there is no network issue and the Sqlclient version is older than .NET 4.5.  You can try to connect to the Windows Azure SQL database via SSMS and check if it can run well. When you
    connect to the SQL Azure database via ADO.NET, you need to verify that the server name and passwords are right in the connection string.
    For more information, you can review the following article about how to connect to Windows Azure SQL Database using ADO.NET.
    http://msdn.microsoft.com/en-us/library/windowsazure/ee336243.aspx
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How do I set up Azure Sql Server to have multiple instances?

    Hi all;
    We are setting up a new SAAS application on Azure and while we have used Azure before, not at this level of multiple apps, etc.
    We plan to have both a web app and a cloud app in both a US and EU data center. They need to hit a common database because requests will go to the closest data center via traffic manager and a lot of the data works off of the customer table. And a customer
    (company) can have users in both the U.S. and E.U.
    Is there a way to set up Azure Sql Server so it has instances in both data centers, and Azure keeps them synchronized? If I understand sharding right, that is not what we need as someone hitting either data center could be requesting any of the data in the
    DB.
    thanks - dave
    What we did for the last 6 months -
    Made the world's coolest reporting & docgen system even more amazing

    Hi,
    As far as I am aware, when you set the webapp/cloudapp to connect to a database you will have to specify the connection string in the app. The app will hit the database which is mentioned in the  connection string you have specified. So it is not automatic
    or Traffic manager. You have full control over it as you can tell your app to connect whichever database you want.The database could be located in any region, however the you have to keep latency in mind as the app in US Datacenter could be calling the Database
    in EU, if that is  they way it is setup.
    You can have separate databases in each region and use Azure Data Sync
    to have the database synchronized, however please keep in mind that Azure Data Sync is in Preview.
    Regards,
    Mekh.

  • Azure SQL Data Sync, LINQ optimization bug

    How can I report the following Bug ?
    var empty = new Set<int>();
    var query = storage.table.Where(item => empty.Contains(item.id));
    // Entity Framework Extended
    query.DeleteAsync()
    The query is optimized to something like this, because the set is empty, and therefore the result set is always empty:
    SELECT
    CAST(NULL AS uniqueidentifier) AS [C1],
    CAST(NULL AS uniqueidentifier) AS [C2],
    CAST(NULL AS int) AS [C3],
    CAST(NULL AS int) AS [C4],
    CAST(NULL AS datetime2) AS [C5],
    CAST(NULL AS varchar(1)) AS [C6],
    CAST(NULL AS int) AS [C7]
    FROM ( SELECT 1 AS X ) AS [SingleRowTable1]
    WHERE 1 = 0
    Now the problem is that update and delete trigger, introduced by Azure SQL Data Sync, will fail because they require the primary key, which is not part of the optimized query. Meaning that when the set is empty the triggers will fail, but if the set contains
    an id, the query is not optimized and therefore will succeed.
    (SELECT [i].[PrimaryKeyId] FROM DELETED AS [i])
    Notice, the problem here is not Entity Framework Extended from my perspective, but the Azure SQL Data Sync Triggers! 

    not sure if i understood your post correctly, but the columns available in the logical inserted and deleted tables available in the trigger are the actual columns of the table itself, not the columns in the query that caused the trigger to fire.

  • Connecting to Azure SQL database in Access 2010

    I've recently purchased a new computer and I had an OBDC connection set up to link to a sql database in azure through access. I am trying to set it up on my new computer but I'm unable to define the specific database. I'm able to make the connection but
    it only allows me into the master database. I've added my IP address in the configure servers but still can't get things to work. Any help would be greatly appreciated.
    thanks
    Lynn

    Hi,
    The following guidelines apply to SQL Database connections using ODBC:
    • When using SQL Server Native Client from SQL Server 2008 R2 or SQL Server 2008, the connection string must include the server name as part of the user name (user@server).
    • You must use TCP/IP as the protocol when connecting to an Azure SQL Database.
    • You cannot create a table in the master database, so therefore you must create a user database to create a table.
    • You cannot execute a use database command to switch to your user database. You must disconnect and connect directly to the user database.
    • You must have a primary key or clustered index on your table to be able to insert data.
    Ref:
    https://msdn.microsoft.com/en-us/library/azure/hh974312.aspx?f=255&MSPPError=-2147217396
    http://blogs.office.com/2010/06/07/access-2010-and-sql-azure/
    https://support.microsoft.com/en-us/kb/2028911/
    Hope this helps you.
    Girish Prajwal

Maybe you are looking for