Alternatives to CONTEXT_INFO on SQL Azure

Hi,
We use CONTEXT_INFO in an application we currently are looking to move to SQL Azure however CONTEXT_INFO is already used to troubleshooting purposes by SQL Azure. Are there any built in alternatives in SQL Azure?
Thanks,

Hmm, still no answer since August of 2010?  I hope MS has something for us that use this.  I'll give an example I use CONTEXT_INFO in an applicaiton.
I use CONTEXT_INFO to prevent users from modifying a table using SQL Studio.  I do this by setting a CONTEXT_INFO in my c#/vb code like so after a begin transaction, along with other TSQL commands, I have this little guy.
    DECLARE @x varbinary(4); SET @x = cast(-1 as varbinary(4)); SET CONTEXT_INFO @x
update dbo.CusCharges set PaymentAmount=5 where CusChargeAmount=10 and CustomerId=30
So then in a particular table, in the trigger (after update, insert) I have this piece of code (shown below)This will allow my application to update the table, but casual TSQL users which don't know about this won't be able to perform an update to this table directly.This works great, except in Azure-land where sysprocesses is not available. So how can I pass down a special variable to a trigger in the context of a transaction?If course, someone could still use TSQL studio, but they would really need to examine the trigger and know what they are doing. This just prevents thebeginning DBA from wiping out Customer Charges for the past decade in a table (it's happened, which is why I put it in).  declare @SessionNid int
    select @SessionNid = cast(substring(CONTEXT_INFO,1,4) as int) FROM master.dbo.sysprocesses WHERE spid = @@SPID
    if @SessionNid = 0 begin
        raiserror('You cannot directly modify dbo.CusCharges.', 16, 1)
        rollback transaction
        return
    end

Similar Messages

  • No OFFSET command in SQL Azure?

    Note: I am a noob at working with databases, as will likely be clear.
    I just upgraded my website to use AzureWebsite's built-in SQL database, upgrading from the SQLCE (.sdf) files that came with the default WebMatrix install.  As part of this process, my local database now appears to be a SQLExpress Server (SQL Server
    10.50.4000 is what it says in the Server Management Studio).
    My OFFSET commands no longer seem to work.  It works when I upload the code to Azurewebsites, but locally, the following command: 
    Line 134: var sqlGetImage = "SELECT * FROM CandidateImage WHERE CandidateID= @0 ORDER BY CandidateID OFFSET BY @1 ROWS";
    Line 135: var qImg = gdb.QuerySingle(sqlGetImage,candidate,rndImage);
    Returns the following result:
    Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'OFFSET'.
    I kind of need OFFSET to do what I want to do in a non-terrible way (I want to choose a random candidate out of the possible SELECT results).  My question:
    1) Is there a way to do what I want to do that works on both platforms?  Or alternatively
    2) Do I have my development environment set up wrong?  It's hard to imagine most people work in a way where this is possible.

    Hi Damion Schubert,
    According to your description, we need to verify if you want to use offset and fetch to be added after the ORDER BY clause in SQL Azure database and SQL Server database. If yes, in Windows SQL Azure
     database, it support ORDER BY with OFFSET and FETCH. However, the form of OFFSET and FETCH is a new T-SQL features in SQL Server2012. Since your local database is SQL Server Express 2008R2, when you use offset function, it will occur error.
    Usually, with earlier version of SQL Server , to accomplish paging , we are using the ROW_NUMBER. Since SQL Server 2012 we can use the keywords OFFSET and FETCH where OFFSET is the number of row to skip and FETCH the number of row to take. For more information,
    you can review the following article.
    http://blog.clicdata.com/2013/05/03/paging-with-sql-server-2012-and-sql-azure/
    http://dbadiaries.com/new-t-sql-features-in-sql-server-2012-offset-and-fetch
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Sp_addextendedproperty is not available in sql Azure

    Please specify some sort of alternative of 
    sp_addextendedproperty in sql azure

    Hi sonesh,
    According to your description, since the issue regards SQL Azure database. I will help you move the question to the Windows SQL Azure forums at
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=ssdsgetstarted.It is appropriate and more experts will assist you.
    In addition, sp_addextendedproperty is not available in SQL Azure databases now. When you create table in SQL Azure database, the columns and other objects can declare with the following comments or you can use a special build of SQL Compare.
    http://stackoverflow.com/questions/12458292/how-do-you-comment-your-db-schema-objects-in-sql-azure-database-project
    http://sqlblog.com/blogs/john_paul_cook/archive/2010/09/12/sql-azure-differences.aspx
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • "The CREATE USER statement must be the only statement in the batch" in SQL Azure - why? what to do?

    I'm getting an error on a line in the middle of a larger sql script, only in SQL Azure.
    IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'foouser')
    CREATE USER [foouser] FOR LOGIN [foouser] WITH DEFAULT_SCHEMA=[dbo]
    GO
    Error: "The CREATE USER statement must be the only statement in the batch."
    I don't actually understand what 'the only statement in the batch' means.
    What is a batch? Is it a SQL file? Is it related to a 'GO' statement or an 'IF' statement? What is the reason for the error? And how do I avoid it?
    Thanks,
    Tim

    >IF...ELSE imposes conditions on the execution of a Transact-SQL statement
    I understand the general purpose of an If statement. I could let go of our definition of statement counting disagreeing too except that because of the error I'm stuck.
    It's less important for Create User but what I am really puzzled over now is a very similar issue how am I supposed to do a safe version of CREATE LOGIN, when I don't know whether a login has been previously created on the server or whether I
    am setting up the database on a clean server?
    IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = N'foouser')
    CREATE LOGIN [foouser] WITH PASSWORD = 'asdfasdf'
    GO
    If I try and execute this script, it throws the same error as above.
    The first unworkable workaround idea is to omit the if statement
    CREATE LOGIN [foouser] WITH PASSWORD = 'asdfasdf'
    GO
    But if the login already exists on the server (because a similar script was already run), then the script throws an error.
    The second unworkable workaround idea is to do
    DROP LOGIN [foouser]
    GO
    CREATE LOGIN [foouser] WITH PASSWORD = 'asdfasdf'
    GO
    Obviously this throws an error in the second block if the login doesn't already exist on the server.
    The third workaround idea I have is to go conditional by putting an IF condition around DROP instead of CREATE:
    Unfortunately that doesn't work for me either!
    "The DROP LOGIN statement must be the only statement in the batch"
    (This is despite the fact that 'drop login' is listed on the
    supported commands page, not the partially supported page..?! Which disagrees with the notes on
    this page.)
    Anyway the real question I am interesting in addressing is: is there actually a way to have a 'Create/Delete login
    if exists' operation which is SQL-Azure compatible and doesn't throw me error messages (which messes with the sql execution tool I am using)?
    If there is no way, I would like to believe it's because it would be a bad idea to do this. But in that case why is it a bad idea?
    Tim

  • How to add description of a column of a table in SQL Azure

    Hi
    I have some tables in my application database where there are descriptions added against certain columns. Needless to say they were done by using sp_addextendedproperty.
    Now I am trying to migrate the Database to SQL Azure. SQL Azure does not support sp_addextendedproperty.
    Hence I am not able to figure out how to add descriptions to those columns.
    Any help would be much appreciated.
    Thanks
    Soumyadeb

    Hello,
    Just as Latheesh post above, Windows Azure SQL database are not support extended stored procedures. That’s one of the limitations on SQL database, and I don’t know there is another way to achieve the same on Azure.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Cannot refresh data in Excel Services with SQL Azure databases

    I am using Excel Services on a SharePoint Online.
    I get my data from a SQL Azure. When i create my Excel repor with Excel 2013 pro I have no problem. So I upload my file on my Sharepoint and try to refresh data.
    Connexion : Power Query - RPT_Event_ByEventType 
    Erreur : Erreur sur site (OnPremise) : Sorry, the data source for this data connection isn't registered for Power BI. Ask your Power BI
    admin to register the data source in the Power BI admin center. 
    I do not understad why I get that error because my data source is on Azure why It told me "OnPremise" ?

    hi,
    >> this button of excel gets just address of web and have button for import it
         i test it by rest API project , but doesn't work, do you know how it is work?
    Do you mean that you don't know how to get the table? You may input the site address into the address box, and then click go button nearby, select the table you want to import into the Excel. Then click import button.That also works for  rest API,
    and your rest API should get the data that you want
    By the way, this is the forum for discussions about Excel develop(VBA ,customization), better to go to TechNet forum for Excel for Excel features question, so that you could get more professional help.
    Best Regards
    Lan
    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.

  • SQL Azure - Intermittent The wait operation timed out

    I have a website engine which runs a few hundred "white label" sites. It's hosted on Azure with a SQL Azure Business database. Generally everything is fine - it all works and runs at a good speed.
    However, throughout the day I get maybe 40 or 50 of the error:
    System.ComponentModel.Win32Exception: The wait operation timed out
    Please don't refer me to the connectivity blog at http://blogs.msdn.com/b/sqlazure/archive/2010/03/22/9982979.aspx as this seems to refer to problems where you just can't connect. My problem is that it's fine most of the time, but I still get these
    intermittently.
    This is sometimes on the main database, but we're also using a database for sessions and this gets the errors too. Both databases are on the same server.
    I also get errors like: 
    An existing connection was forcibly closed by the remote host
    and:
    System.Data.SqlClient.SqlException: The service has encountered an error processing your request. Please try again. Error code 40143. A severe error occurred on the current command. The results, if any, should be discarded.
    and, when evil bots are hammering the site:
    System.Data.SqlClient.SqlException: Resource ID : 1. The request limit for the database is 180 and has been reached. See 'http://go.microsoft.com/fwlink/?LinkId=267637' for assistance.
    Each website can potentially have a Google footprint of around 10,000 pages. The result it that bots are hitting the sites regularly, indexing lots of pages for hundreds of sites. I also have some worker roles doing data work. The database is clearly busy!
    I am hoping to add 2 or 3 times the number of sites that I currently have to the "engine". 
    I am looking at efficiency where possible, but the sites are clearly under a fair load from bots and visitors.
    My question is, will one of the upgrades from Business to S2, P1, P2 or P3 resolve these problems? The financial cost of these database instances stagger greatly so I wouldn't want to update and find I'm left with the same problems but am paying many times
    more each month.
    Thank you in advance.

    Hello,
    For Web/Business edition database, the maximum limit of concurrent requests is 180. Beyond this limit, you will receive error.
    The Max woker threads for Standard(S2) is 100, you should upgrade your database to Permium tier.
    The concurrent requests limit of premium database varies depending on the reservation size of a premium database. For example, for P1, the max worker threads is 200.
    Reference:Azure SQL Database Resource Governance
    Azure SQL Database Service Tiers and Performance Levels
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Performance is too slow on SQL Azure box

    Hi,
    Performance is too slow on SQL Azure box (Located in Europe)
    Below query returns 500,000 rows in 18 Min. on SQL Azure box (connected via SSMS, located in India)
    SELECT * FROM TABLE_1
    Whereas, on local server it returns 500,000 rows in (30 sec.)
    SQL Azure configuration:
    Service Tier/Performance Level : Premium/P1
    DTU       : 100
    MAX DB Size : 500GB     
    Max Worker Threads : 200          
    Max Sessions     : 2400
    Benchmark Transaction Rate      : 105 transactions per second
    Predictability : Best
    Any suggestion would be highly appreciated.
    Thanks,

    Hello,
    Can you please explain in a little more detail the scenario you testing? Are you comparing a SQL Database in Europe against a SQL Database in India? Or a SQL Database with a local, on-premise SQL Server installation?
    In case of the first scenario, the roundtrip latency for the connection to the datacenter might play a role. 
    If you are comparing to a local installation, please note that you might be running against completely different hardware specifications and without network delay, resulting in very different results.
    In both cases you can use the below blog post to assess the resource utilization of the SQL Database during the operation:
    http://azure.microsoft.com/blog/2014/09/11/azure-sql-database-introduces-new-near-real-time-performance-metrics/
    If the DB utilizes up to 100% you might have to consider to upgrade to a higher performance level to achieve the throughput you are looking for.
    Thanks,
    Jan 

  • Link a Crystal Report report with an SQL Azure database

    Hi,
    I want to use my database on SQL Azure in Crystal Report. So I want to link my reports with data contained not in a local db, but in a SQL Azure one.
    Insiede Crystal Report I have created a new ADO connection to my SQL Azure, providing server, db, user, password, and Crystal Report have recognized the database. But when I go to the Database Expert and I try to set this ADO connection inside my report,
    I recieve this error:
    "Not Implemented
    Source ADODB.Connection
    L'operazione richiesta non è supportata dall'oggetto o dal provider (operation not supported by the object or by the provider)"
    Why? How can i use my SQL Azure data in my Crystal Report reports?
    Thanks

    Hi Delfins,
    Please create a UDL file to test the connection, ensure the connection is fine and then use the same connection string in your Crystal Report.
    For UDL file, you can refer to:
    http://msdn.microsoft.com/en-us/library/e38h511e(VS.71).aspx
    Hope this helps,
    Raymond
    Raymond Li - MSFT

  • Unable to save a report that includes a datasource of "Microsoft SQL azure" type

    I have install SSRS in azure using the following instructions (http://msdn.microsoft.com/en-us/library/dn449661.aspx) and all seems to work fine, however when I create a report in report builder 2014 (in this case empty) that includes a Microsoft SQL Azure
    datasource type I am unable to save the report and get the following error message (even though when I test connection it succeeds). 
    "The report definition was saved, but one or more errors occurred while setting the report properties"
    Reports with standard sql datasources work fine.
    I have also tried creating the report using Visual Studio 2013 and get a similar error message.
    I have tried this using SQL 2012 and SQL 2014 and get the same error.
    Does anybody know how I can create a report with Microsoft SQL Azure datasource type?

    Hi jamesla,
    Based on my research, the issue can be caused by a deleted shared data source still exist under the Data Sources list in Report Builder. For more details about this scenario, we can refer to the following thread:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/7170dbee-048c-4298-89ba-df4d42924c8e/the-report-definition-was-saved-but-one-or-more-errors-occurred-while-setting-report-properties?forum=sqlreportingservices
    Since the error message without detail information, we can try to render the report to see the detail error message. Besides, we can try to check it in the log file. The SQL Reporting Services log files are found on the reporting services point server, in
    the folder %programfiles%\Microsoft SQL Server\<SQL Server Instance>\Reporting Services\LogFiles.
    For more information about how to use Microsoft SQL azure as the data source of a report, please see:
    http://msdn.microsoft.com/en-IN/library/ff519560.aspx
    http://programming4.us/database/2158.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Create a web site in Visual Studio - fails with SQL Azure V12

    Creation of Microsoft Azure Website failed. <Error xmlns="Microsoft.SqlServer.Management.Framework.Web.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Message>The service objective 'Web' specified is invalid.</Message><InnerError
    i:nil="true"/><SqlErrorCode>40804</SqlErrorCode><Severity>16</Severity></Error>
    I receive this error after connecting to a database using the Preview Edition of SQL Azure V12 with a service level of 'Basic'
    'Web' may need to be changed to 'Basic' or 'Standard' depending on the service level. How can I do this?
    Regards
    David

    Hi,
    Thanks for posting here.
    Upgrading Web and Business Databases
    Upgrading Web or Business databases to a new service tier/performance level does not take the database offline. The database will continue to work through the upgrade operation. At the time of the actual transition to the new performance level temporary
    dropping of the connections to the database can happen for a very small duration (typically measured in seconds). If an application has transient fault handling for connection terminations then it is sufficient to protect against dropped connections at the
    end of the upgrade.
    Upgrading a Web or Business database to a new service tier involves the following steps:
    Determine service tier based on feature capability
    Determine an acceptable performance level based on historical resource usage
    Why does existing performance for my Web or Business database map to the higher Premium levels?
    Tuning your workload to fit a lower performance level
    Upgrade to the new service tier/performance level
    Monitor the upgrade to the new service tier/performance level
    Monitor the database after the upgrade
    Refer:
    http://azure.microsoft.com/en-us/documentation/articles/sql-database-upgrade-new-service-tiers/
    https://msdn.microsoft.com/en-us/library/azure/dn741336.aspx
    Hope this helps you.
    Girish Prajwal

  • Unable to drop SQL azure table

    Hi,
    I'm trying to drop SQL azure table. However I can delete data inside the table. When using drop command, it is taken long time processing and finally this error message 'Connection Failed'. Please help me. Thanks

    That sounds like an internal error in SQL Server which may be due to corruption. Don't really know how you deal with that in Azure. But if DBCC CHECKDB is available, run it and see what happens.
    Also, do you have any DDL triggers on the database? In such case, disable the trigger, in case it is the trigger that is failing.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SQL Server 2012 Deploy Database to SQL Azure...

    I have spent many days trying to copy a simple test database from my PC to SQL Azure but with little success.  Then I installed SQL Server 2012 and see a new task:
    Deploy Database to SQL Azure...  It looks like an automated extraction to DAC and then creating the Azure database all in one step.
    I was elated, but got hit with the following three types of errors.
    One or more unsupported elements were found in the schema used as part of a data package.
    Error SQL71564: The element Extended Property: [dbo].[Accounts].[Address].[MS_Description] is not supported when used as part of a data package (bacpac).
    Error SQL71564: Table Table: [dbo].[Activities] does not have a clustered index.  Clustered indexes are required for inserting data in this version of SQL Server.
    Error SQL71564: Element User: [NT AUTHORITY\NETWORK SERVICE] has an unsupported property AuthenticationType set and is not supported when used as part of a data package.
     (Microsoft.SqlServer.Dac)
    May I know what I can do on the on-premise database to rid of the first and third error?
    Thanks.

    Hello,
    1) Remove the Extended Property from the (?) column Address in table Accounts.
    BTW, for small databases it's sometimes easiere to generate a script for the database (and modify it slightly) instead of using the Wizard
    Olaf Helper
    Blog
    Xing
    What is Extended Property?   What is this .MS_Description?   I can't see it in the table designer or the Column Properties.  (I don't know whether this was corruption caused by Data Sync I used earlier.)  How do I remove it.
    Of all the methods of copying SQL Server to Azure SQL, this one gives the least mistakes.  If I can solve this Extended Properties thing hopefully I can migrate the database over.

  • Can't create a new SQL Azure Standard Tier db

    I'm having an issue creating a new sql azure standard tier db. Here's the basic steps I've done to migrate a web tier db.
    Register for the sql preview programme
    https://account.windowsazure.com/PreviewFeatures
    Perform a db export to blob storage
    use the + (new) button to create a new SQL db
    select the import option
    browser to your saved export
    hopefully see the new tiers as options in dialog. 
    The new tiers require a separate server to web. Can create this from the import dialog
    I have 2 independent azure accounts, the above process worked for my test account but for the live account where I was also experimenting after success on the test account I hit an issue. I request to create a new server whilst importing. This step seems
    to work but then the actual import fails with this msg
    "Error encountered during the service operation. 
     Could not import package.
     Error SQL72014: .Net SqlClient Data Provider: Msg 40823, Level 16, State 1, Line 1 Invalid value provided for parameter EDITION. Please provide a value that is valid on server version 1.0.
     Error SQL72045: Script execution error. The executed script:
     CREATE DATABASE [$(DatabaseName)] COLLATE SQL_Latin1_General_CP1_CI_AS
     (EDITION = 'Standard', MAXSIZE = 1 GB)"
    Tried a couple of times but no joy. Using the portal I can browse to the new sql server and it looks okay other than the list of ENABLED
    RESERVATION SIZES ONLY HAS P1, P2, P3 I'm requesting a standard (s1) db not premium (P1, P2, P3). On my test server I see in this list also S1,
    S2. As you can see in the error message I'm requesting Edition = Standard. I get the feeling the newly created server is not accepting standard tier dbs?
    Now the server is created if I try an import I see the server in the list of available servers but when I select a tier of Basic or Standard the new server is grayed out, not so if I select Premium or the older Web or Business? Interestingly my current live
    sql server shows up as supporting the new premium?
    Thanks
    Wayne 

    Hello,
    Glad to hear that the issue resolved and thanks for your sharing.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • SQL Azure Reporting - There was an exception running the extensions specified in the config file. --- Maximum request length exceeded.

    I am trying to deploy an RDL file (5MB) to SQL Azure Reporting server in South Central US using the deploy function in SQL Server Data Tools but facing the following error during deployment to Azure Reporting server.
    "There was an exception running the extensions specified in the config file. ---> Maximum request length exceeded."
    Is there any limit on the size of RDL files which can be deployed to Azure Reporting server? I have seen some online posts which talk about increasing the maxRequestLength in httpruntime of web.config in Reporting server. But in case of Azure Reporting server
    how can be make modification to this configuration?
    I have tried to upload it directly to SQL Azure Reporting server from the Management Portal --> Upload Report function which still resulted in error.
    Thanks & Regards, Deep

    Thanks for your question. Unfortunately we are in the process of deprecating SQL Reporting services.  Full details are available at http://msdn.microsoft.com/en-us/library/gg430130.aspx
    Thanks Guy

Maybe you are looking for

  • Audigy 4 Pro - Remote Contr

    Hey,?I've got an Audigy 4 Pro card which i've had from new since 2005.However, i've only ever had the remote control working once, around about the time i first installed the card. Since then it's not worked. I'm currently running the latest drivers

  • Print from Macbook Pro to HP PSC 1215 all in one on Windows 7

    If I print from my new Macbook pro wirelessly to the HP PSC 1215 All in One connected to a USB port  on a Windows 7 PC, the print job appears in the queue on the Windows 7 PC, the printer on/resume light starts to flash, the printer makes a few click

  • Where can I get my audio driver?

    The model number is  610-1068cn,made in China,and the pre-installed system is win7  64-bit  ,  I've changed it to 32-bit.  Where can I find the audio driver ?  The type of the sound card is IDT 92HD89D3 , anyone who knows ,please mail to me, thank yo

  • After installing windows 8 can't display bookmarks

    I like to have the bookmarks displayed on a sidebar, but since installing windows 8 on my new Pc, I can't find the display sidebar bookmarks in the menus on latest Firefox instillation.

  • What exactly does 'zpool iostat' measure?

    Hi there, I am wondering what exactly get measured wher i do an 'zpool iostat [-v]' on a machine, especially regarding the write values. Do those consist only of the writes to the ZIL or do they include the following commits, too? Thanks in advance,