Is there a way to create a plan guide for this query?

How can i create a plan guide for this query,suppose i can't change the query text:
USE AdventureWorks2008R2;
GO
SET NOCOUNT ON;
GO
-- query plan statement starts
DECLARE @Group nvarchar(50), @Sales money;
SET @Group = N'North America';
SET @Sales = 2000000;
SET NOCOUNT OFF;
SELECT FirstName, LastName, SalesYTD
FROM Sales.vSalesPerson
WHERE TerritoryGroup = @Group and SalesYTD >= @Sales;
-- query plan statement ends
AdventureWorks2008R2's parameterization option is simple, i want this type of query can reuse plan:
DECLARE @Group nvarchar(50), @Sales money;
SET @Group = N'Other Country';
SET @Sales = 88;
SET NOCOUNT OFF;
SELECT FirstName, LastName, SalesYTD
FROM Sales.vSalesPerson
WHERE TerritoryGroup = @Group and SalesYTD >= @Sales;
I tried many times ,but it didn't work:
declare @xml nvarchar(max) -- the plan i want to reuse
set @xml = (select cast (query_plan as nvarchar(max)) 
from sys.dm_exec_query_plan (0x060006001464570B405D92620200000001000000000000000000000000000000000000000000000000000000))
-- create plan guide 
exec sp_create_plan_guide 
@name ='Test'
,@stmt=N'SELECT FirstName, LastName, SalesYTD
FROM Sales.vSalesPerson
WHERE TerritoryGroup = @Group and SalesYTD >= @Sales;'
,@type =N'sql'
,@params =N'@Group nvarchar(50), @Sales money'
,@hints = @xml;
Thanks.

I guess you don't wanna fire these queries "adhoc" but prepared instead to reuse the plan:
exec sp_executesql N'SELECT FirstName, LastName, SalesYTD FROM Sales.vSalesPerson WHERE TerritoryGroup = @Group and SalesYTD >= @Sales',
N'@Group nvarchar(50), @Sales money', N'Other Country',88
exec sp_executesql N'SELECT FirstName, LastName, SalesYTD FROM Sales.vSalesPerson WHERE TerritoryGroup = @Group and SalesYTD >= @Sales',
N'@Group nvarchar(50), @Sales money', N'North America',2000000
Bodo Michael Danitz - MCT, MCITP - free consultant - performance specialist - www.sql-server.de

Similar Messages

  • Is there a way to create a coorporate account for Itunes?

    Is there a way to create a coorporate account for Itunes?

    Yes, but it's a series of 3 corporate accounts: VPP manager, VPP Facilitator,  end user
    See this documentation I just posted today to this forum
    https://discussions.apple.com/message/19437873#19437873

  • Is there a way to create a fade only for the first loop?

    I have a loop (Modern Guitar Rock 04), which I've extended out so it repeats four times. I select the Fade Tool and X-Fade for drag. I then drag just in front of the loop and onto it, which creates a fade. However, this also creates fades at the beginning of the repeating loops. Is there a way to create a fade only for the first loop?

    The loop function always repeats the same region so of course the fade is also copied. So option+drag the original region to make a (non clone) copy, fade the first region and loop the second one (which you just copied).

  • Is there a way to create a "common desktop" for all RD/TS 2012 users? (Office 2010 icons on the dekstop, for example.)

    Hello!  Just like the title, is there a way to create a "common desktop" for all RD/TS 2012 users?
    I know how to do this using regular W7 workstations and 2008 Servers, but the "Default" folder under the USERS directory is gone and I'm not sure how to get the icons there in Windows 8, let alone Server 2012 Remote Desktop.
    I've installed Office 2010 on the 2012 server, but every end user that logs in has to manually type in "Word," "Excel." "PowerPoint." etc from the metro interface, then right-click each icon to add the shortcut to the desktop.
    Given the... uh.. unfamiliarity of our endusers around the computer, this really isn't the best option.  What I'd like is them to log on and have all the Office icons ready and availible for them.
    Any ideas?
    Matthew J. Fazio

    Hi,
    You can edit the local GPP and create a desktop shortcut for all users.
    Reference:
    Customize the default local user profile in windows Server 2012
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/3f178a0e-128e-4f4f-870a-90c8bbf1afeb/customize-the-default-local-user-profile-in-windows-server-2012?forum=winserver8gen
    Also, you can use CopyProfile to customize the Default User Profile.
    Customize the Default User Profile by Using CopyProfile
    http://technet.microsoft.com/en-us/library/hh825135.aspx
    Best Regards.
    Jeremy Wu
    TechNet Community Support

  • Is there any way to create admin role only for one resource.

    Hi all,
    I am trying to create an admin role with 'update user' capability. But I want to restrict the user(with the admin role) to be able to update a user's attribute only for one resource, The user(with the admin role) should not be able to update the attributes of the other resources which a user have.
    Is there any way to create admin role only for one resource?
    I customized the tabbed user form to show only one resource attribute (deleting the missing fields and adding my tab for the resource) and then assigned this new User Form to the user(with the admin role) in security tab.
    It works fine. But the problem is that if any user(with the admin role) is also admin of some other resource then he/she will not be able to view the other resource attributes.
    Please suggest,
    thanks

    The loop function always repeats the same region so of course the fade is also copied. So option+drag the original region to make a (non clone) copy, fade the first region and loop the second one (which you just copied).

  • Can someonoe please assist me in my Adobe Photoshop CS6 Extended.  I keep getting a 'Couldn't Complete Your Request because Dynamic Link is not Available?" Is there a way of getting a software patch for this problem?  I thought you didn't need extra softw

    Can someonee please assist me in my Adobe Photoshop CS6 Extended.  I keep getting a 'Couldn't Complete Your Request because Dynamic Link is not Available?" Is there a way of getting a software patch for this problem?  I thought you didn't need extra software.  My software other than that problem works fine.

    Couldn't complete what request?   Way more information please.
    What operating system?

  • HT4009 IX have an iPad version 4.3 and I had instagram install, like I was having problem I uninstalled it, but now I can't install it again, because my iPad doesn't support the new version, is there a way that I can download instagram for this iPad?

    I have an iPad version 4.3 and I had instagram install, like I was having problem I uninstalled it, but now I can't install it again, because my iPad doesn't support the new version, is there a way that I can download instagram for this iPad?

    Update your iOS.
    If you have an iPad 1, the max iOS is 5.1.1. For newer iPads, the current iOS is 6.1.3. The Settings>General>Software Update only appears if you have iOS 5.0 or higher currently installed.
    iOS 5: Updating your device to iOS 5 or Later
    http://support.apple.com/kb/HT4972
    How to install iOS 6
    http://www.macworld.com/article/2010061/hands-on-with-ios-6-installation.html
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    If you are currently running an iOS lower than 5.0, connect the iPad to the computer, open iTunes. Then select the iPad under the Devices heading on the left, click on the Summary tab and then click on Check for Update.
    Tip - If connected to your computer, you may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. Be sure and backup your iPad before the iOS update. After you update an iPad (except iPad 1) to iOS 6.x, the next update can be installed via wifi (i.e., not connected to your computer).
    Tip 2 - If you're updating via wifi, place your iPad close to your router to preclude getting a corrupted download.
     Cheers, Tom

  • Is there any way to create a wifi hotspot for my macbook using my IPad?, Is there any way to create a wifi hotspot for my macbook using my IPad?

    I am going to a lake cabin in Northern Minnesota for a week and need to get wifi for my Mac.  Is there any way to create a wifi hotspot using my Ipad so that I have internet service for my laptop?

    No, iPad can become a hot spot, but if you have an iPhone, it can tether if you have a data plan that incudes the tethering option.  With AT&T for example, you can add tethering for $20 month or for $45/month, you receive tethering and 4GB of data per month.  If you have the unlimited data plan from AT&T you'll unfortunately have to give it up if you want to tether.  You can also go to almost any carrier and purchase a MiFi unit which may work for you.  Whether iw will work in Northern Minnesota is something only your carrier could answer.

  • Is there a way to create a TINY image for B2G, similar to TINY_ANDROID ?

    Hi, is there a way to create a TINY image from Firefox OS similar to that of TINY ANDROID image which is used for Kernel Development. Android gives an option to create with the flag BUILD_TINY_ANDROID, just wanted to know if there is anything similar in Firefox OS.
    If there is no support from B2G, can we still create one?
    Any suggestions would be very helpful.
    Thanks

    I'm not sure that anybody here would know the answer to this. I'd suggest asking in #b2g on irc.mozilla.org. In case you don't have an IRC client, here's a web-based one: https://kiwiirc.com/client/irc.mozilla.org/#b2g . A lot of the b2g developers tend to hang out in there, and if anybody knows, they would.

  • Is there a way to create a commentary file for the summary screen?

    I am not seeing the summary screen in the list of commentary files in the \Development\include\commentary\en-CA\screen path. Is there a way to create a commentary for the summary screen?
    Thanks all.

    thanks Kristy,
    I'm not sure of the best way to add any requests we have for future releases.
    If there is one, let me know what is best.
    Here is what I want to add.
    In the properties file, one can set decision report preferences for an attribute - for invisible and silent.
    I wish we could also set preferences for bold, and given that, I guess it makes sense to be able to set preferences for italic and underline
    While these can be addressed through custom properties and XSLT, it obviously would be easier for the modeler to be able to select the attribute enhancement in the properties file. Given that decision reports can get very long, and there are attributes which might be better highlighted in some way, this would be a great approach.

  • Is there a way to create a PRIVATE folder for some of my audiobooks?

    Hello,
    This might sound cheesy, but I would like to keep some of the audiobooks in my iTunes private and I'm wondering if there's a way of doing it? For example, can I create a second Audiobooks folder and keep there? Is there a way to make that folder password protected, so no one else can look in it?
    Any help with this would be appreciated!
    Thank you.

    Where would I keep my audiobooks?
    Your Audiobooks stay where they are.
    You can decide which playlists your computer shares, as follows:
    Open iTunes Preferences. Click on "Sharing". Instead of having the button "Share entire library" checked, change it to "Share selected playlists" and select only the playlists that you want others to see.

  • Using FormCentral is there a way to create a drop down for a date?

    In using a previous version of Adobe Professional, in designing fillable PDF forms we were able to create a field with a drop-down date.  Is there any way to do this using FormCentral?

    I think want you are asking is if it is possible for to have a Date Field which when the user click on the field a calendar comes up to pick a date?
    If that is the case then the PDF generated by FormsCentral doesn't support this yet.
    I am guessing that you were using LiveCycle Designer to create forms in the past. The some forms generated by LC Designer does support this type of field.
    If you want to see this added in FormsCentral PDF you can submit a idea here : http://forums.adobe.com/community/formscentral?view=idea&ideaView=5515 (click on the "Create an Idea" link on the right)
    Gen

  • Is there a way to create a .dmg file for a DVD inserted into the system

    I am wondering if Snow Leopard has integrated any tools that can create a .dmg file for the CD or DVD inserted into the system?
    If not, any recommendations for freeware 3rd party tools? Thanks

    Insert the disc you want to create the .dmg from, then choose the disc in the left hand pane of Disk Utility. From the File menu, choose New > Disk Image from (name of disc).
    EDIT: This is basically how it's done; however, there may be other steps involved, depending on the type of disc you're trying to copy and what your goals are with the .dmg. If you provide more details about what you're trying to achieve, maybe we can help you further.
    Message was edited by: Tuttle

  • Is there any way to create an apple id for a minor child without a credit card

    I only have debit cards.  I have three VISA debit cards with CVVs but they are all linked to bank accounts.  I don't have credit cards because I don't want the debt or interest rates associated with them.  I have several apple devices at my house for myself and my son.  We cut the cord on cable a while ago and only use apple TV boxes.  With the TVs, iPads, iPhones, iMac, and Macbook Air all needing an apple id, we have far exceeded my five device limit.  I feel as if I am being punished for my devotion to apple and it's products since I can't use half of them with my apple id and cannot create one for my son because of my fiscal responsibility.  There must be a way around this.  I'm not going to sign up for a credit card for the sole purpose of getting my son an apple id.  Any suggestions?

    For Family Sharing, why must I add a credit card to add a child? Please explain why my debit card, on file, isn't enough…
    Create an iTunes Store, App Store, or iBooks Store account without a credit card or other payment method - Apple Suppor…
    Family Sharing and Apple IDs for kids - Apple Support
    Set up and manage iTunes Allowance - Apple Support

  • Is there a way to create a loopback adapter for the mac?

    In the MS world, there is a MS Loopback adapter, that allows to create a virtual network card and simulates that there is a LAN cable connected to it.
    I would like to see if there is a way to do that in the mac world.
    I found this link and I believe is a hint, but I'm not sure if is going to work, I don't want to try it and damage my network settings.
    Thanks in advance for your help.
    Greg

    Here is the link I found http://stackoverflow.com/questions/87442/virtual-network-interface-in-mac-os-x
    I have VMWare Fussion running on my MAC, but I want to use IIS on my 2003 Server in VMWare, and I want to browse from Safary to my application running on IIS.
    Thanks in advance for your help.
    Greg

Maybe you are looking for