Need a query,which will do a comparison and if it doesnt satisfy the condition it should raise an error by using raiserror statement

I have a Table called Test_ X in which there are two fields:
1) date_value
2)Application_Name
requirement: we have to calculate the number of days ramaining through date_value field and  compare it to  with n days.
if it is less than n days it should raise an error through raiserror statement.
I get the below logic to get the no of days before expiry:
select GETDATE() 'Today Date',
date_value 'expiry date',
abs(DATEDIFF(dd,date_value,getdate()))'No of days before expiry'
from dbo.Test_X
where Application_Name='xyz'
With above satatement am able to get the Number of days before expiry .
my question is how to comare it with a variable say n days and if is less than n days it should raise an by using raiserror statement .
Please help or advice.

You can use variables in the RAISERROR, but not expressions, e.g.
DECLARE @Days INT;
SET @Days = ABS(datediff(day, '19000101', CURRENT_TIMESTAMP));
RAISERROR (
N'This is message %s %d.'
,-- Message text.
10
,-- Severity,
1
,-- State,
N'number'
,-- First argument.
@Days
);-- Second argument
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • I need to reinstall my original factory disc and reset my computer to the beginning. It currently has lion. Do I need to erase my HD first to clear and make new room for the install disc.

    I need to reinstall my original factory disc and reset my computer to the beginning. It currently has lion. Do I need to erase my HD first to clear and make new room for the install disc.

    Prepare Your Mac for Sale
    Boot from the OS X Installer Disc One that came with the computer.  After the installer loads select your language and click on the Continue button.  When the menu bar appears select Disk Utility from the Utilities menu.  After DU loads select the startup volume from the left side list then click on the Erase tab.  Set the format type to Mac OS Extended (Journaled) then click on the Options button.  Select the one pass Zero Data option and click on the OK button.  Then click on the Erase button.
    Note: You can skip the Zero Data option if you are not concerned about removing sensitive personal data from the hard drive.  If you choose to skip this part of the process then it is possible for others to recover data from the hard drive.  The Zero Data procedure will prevent others from getting access to your personal information.
    This process will take 30 minutes to several hours depending upon the size of the hard drive.  After formatting has completed quit DU and return to the installer.  Now complete the OS X installation.  At the completion of the installation do not restart the computer.  Instead just shut it off.  The next user will be presented with the Setup Assistant when they turn on the computer just as it would if new out of the box.

  • Which option do I have to select If I buy the latest iPad with cellular feature for international use? If I choose verizon can I just change the sim card and insert one from another country?

    Which option do I have to select If I buy the latest iPad with cellular feature for international use? If I choose verizon can I just change the sim card and insert one from another country?

    I would guess you need the A1460 model
    see here
    http://www.apple.com/ipad/LTE/

  • Plugged in brand new ipad that is still showing the 'itunes' and usb lead as a sign to connect to itunes before it will even start up and my computer is detecting the Apple IPAD 2 camera but Itunes is not picking it up? whats going wrong?

    plugged in brand new ipad that is still showing the 'itunes' and usb lead as a sign to connect to itunes before it will even start up and my computer is detecting the Apple IPAD 2 camera but Itunes is not picking it up? whats going wrong?

    If you're really trying to use Windows 2000, then that's the problem. As you'll see on the box, you need at least XP/SP3.
    Matt

  • I just updated my iTunes, and I need to delete photos from my iPod 4, and there is a Photo Library that synced to my iPod when i plugged it into my computer, and now it doesnt have the option to delete them off my iPod. How do I get rid of these photos?

    I just updated my iTunes, and I need to delete photos from my iPod 4, and there is a Photo Library that synced to my iPod when i plugged it into my computer, and now it doesnt have the option to delete them off my iPod. How do I get rid of these photos? I have read other questions that say to plug the iPod into the computer and like un-sync it, but I downloaded the new iTunes and it doesnt have a photos tab. Does anyone know how to solve my problem? Please and Thank You, Megan!

    Just what did you do to the computer?
    It sounds like the iPodf is seening the iTunes libary as a new libary.

  • I need to reinstall but system was pre-installed and i do not have the apple id used

    I need to reinstall but system was pre-installed and i do not have the apple id used OSX Lion.

    I need to reinstall but system was pre-installed and i do not have the apple id used OSX Lion.

  • Need SQL Query which saves query results to an excel file

    Hi,
    I am looking for a sql query which saves/ export results of an query to a excel file
    Thanks,
    Chetan

    I am looking for a sql query which saves/ export results of an query to a excel file
    Thanks,
    Chetan
    Options:
    1) You can use
    BCP command to export result to excel
    2) Insert into excel by using OPENROWSET
    3) Use Import and Export Wizard and provide SQL query as source and Excel as destination
    Please refer:
    http://stackoverflow.com/questions/87735/how-do-you-transfer-or-export-sql-server-2005-data-to-excel
    http://www.codeproject.com/Questions/617527/Export-sql-query-result-in-excel-file
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • Need xsl function which will convert 100 = One Hundred.

    Hi
    i have to print the number as a text .
    EX:100=Hundred
    In one of the Vetsrini reply i seen this
    ""we have xsl function which will convert 100 => One Hundred.
    If anybody interested to use this function, let me know.
    i will post that in my blog in sometime.""
    Convert Number into words in RTF
    Thanks,
    Ananth.v

    <?xdoxslt:toWordsAmt(100)?>http://winrichman.blogspot.com/2008/08/convert-number-into-amount-in-words.html
    Convert Number into words in RTF

  • Need a query string to a specific point and zoom in a public GIS Flash document

    I am working with a client's website, and have no developer access to the Flash document, only public access.
    I have been given the url for a county map that is presented in an interactive Flash document.
    http://68.156.95.45/newberrygis//#1
    Client would like me to focus in on their specific development, which requires panning the map and zooming in.
    How can I find a query string that will help me to do that?

    The functionality of the GIS map was important. I was given the email for the person in charge of the map, who helped me out. It appeared that he was able to outline the road in the neighborhood that I needed to focus on. That provided a parcel ID, which in turn made it possible to focus in on the proper area. This is supposition on my part; perhaps he has other info that gave him the parcel ID.
    I'm not a huge fan of Flash on other than desktops and laptops, but it is what it is, client needs to use it, I need to help the client out!
    B

  • I just upgraded my OS X 10.6.4 to Mavericks and now my iPhoto '09 needs an upgrade.  Will I lose all my photos if I do the upgrade?

    I upgraded my two Macbook Pro's yesterday to Mavericks, from OS X 10.6.4.  I can't seem to open iPhoto on ONE of them.   I believe it's the same on both computers, iPhoto '09.  So I went in the App store and clicked upgrade my iPhoto. Now it says the library needs to be upgraded to work with this newer version of iPhoto.  Help!  Am I going to lose all my photos?

    I believe it's the same on both computers, iPhoto '09.
    Check the iPhoto versions. The version number should be shown below in the "General" section of the Info panel, when you select iPhoto in the Finder and use "File > Get Info".  With Mavericks you should be using iPhoto 9.5.1.  You can buy the upgrade from the App Store.
    Will I lose all my photos if I do the upgrade?
    No, but never do an upgrade without making a backup of your computer, just in case something is wrong.
    Your photos are in your iPhoto library. After installing the upgraded version,  the iPhoto Library will be upgraded to a new format, when you open it the first time in iPhoto.
    If you want to use your iPhoto Library on both your computers, the iPhoto version should be the same.

  • I upgraded to Snow Leopard, made a change to Address Book that I need to correct, tried to use Time Machine to find the prior version and it keeps pulling up the later ones info. How do I use Time Machine to restore Address Book from a few hours ago?

    This morning, I upgraded to Snow Leopard from v10.5.8. Then, I exported 11 contacts from our old Now Contact database, intending to import that info into Address Book. It was an experiment, as we have 1199 contacts in 20+ categories and want to eventually get them into Bento from Address Book. The export automatically created a file called Export.vcf on the desktop, after I highlighted the 11 contacts. I tried to look at the info, but when clicked it opens Address Book, which then simply asked if I wanted to import the 11 contacts to it. I clicked yes. Then in checking Address Book 7, not 11 contacts appeared. I clicked on "All Contacts" and there were 1630. We only have 1199, so where did the extra 400+ come from? Since I had already clicked twice on the Address Book window, I couldn't undo the import. So I thought 'Ok, I'll trash Address Book and go to Time Machine, find Address Book, go to right after the upgrade to SL, hit Restore and bingo. Nope. I keep getting the post-import info, not pre. Con someone direct me to a solution? I want to get rid of the import contacts plus the extra 300 or so ( I already had a hundred or so in several categories)? Then, I need to figure out (1) why ALL the old records were exported from Now Contact, (2) where they were hiding in that .vcf file when Address Book recognized that I only wanted to export 11, (3) why Address Book showed only 7 imports in the "Last Import" group, but showed ALL my contacts in the "All Contact" group, even though they should nearly all have been safely untouched in the Now Contact DBase file. PS, I am not especially computer savvy. Thanks for any enlightenment.

    Booting From Snow Leopard Installer Disc
    1. Insert Snow Leopard Installer Disc into the optical drive.
    2. Restart the computer.
    3. Immediately after the chime press and hold down the "C" key.
    4. Release the key when the spinning gear below the dark gray Apple logo appears.
    5. Wait for installer to finish loading.
    Drive Preparation and Installation
    1. After the installer loads select your language and click on the Continue button.  When the menu bar appears select Disk Utility from the Utilities menu.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  SMART info will not be reported  on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Click on the Options button, set the partition scheme to GUID then click on the OK button. Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Security button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    7. After formatting is complete quit DU and return to the installer. Install Snow Leopard.

  • Need To Create a table in Sql Server and do some culculation into the table from Oracle and Sql

    Hello All,
    I'm moving a data from Oracle to Sql Server with ETL (80 tables with data) and i want to track the number of records that i moving on the daily basis , so i need to create a table in SQL Server, wilth 4 columns , Table name, OracleRowsCount, SqlRowCount,
    and Diff(OracleRowsCount - SqlRowCount) that will tell me the each table how many rows i have in Oracle, how many rows i have in SQL after ETL load, and different between them, something like that:
    Table Name  OracleRowsCount   SqlRowCount  Diff
    Customer                150                 150            
    0
    Sales                      2000                1998          
    2
    Devisions                 5                       5             
    0
    (I can add alot of SQL Tasks and variables per each table but it not seems logicly to do that, i tryid to find a way to deal with that in vb but i didn't find)
    What the simplest way to do it ?
    Thank you
    Best Regards
    Daniel

    Hi Daniel,
    According to your description, what you want is an indicator to show whether all the rows are inserted to the destination table. To achieve your goal, you can add a Row Count Transformation following the OLE DB Destination, and redirect bad rows to the Row
    Count Transformation. This way, we can get the count of the bad rows without redirecting these rows. Since the row count value is stored in a variable, we can create another string type variable to retrieve the row count value from the variable used by the
    Row Count Transformation, and then use a Send Mail Task to send the row count value in an email message body. You can also insert the row count value to the SQL Server table through Execute SQL Task. Then, you can check whether bad rows were generated in the
    package by querying this table.  
    Regards,
    Mike Yin
    TechNet Community Support

  • HT4623 I did the ios6 software update on my iphone and it did not complete the udate because it said an error occurred. Then it said I needed to restore my phone and when I try to it wont let me restore my back up because it says there's not enough storag

    I did the ios6 software update on my iphone and it did not complete because it said there was an error. It then gave me a message that I needed to restore my phone. When I tried to restore my backup it says it cannot be completed because there is not enough storage. I cant delete anything to make more storage because my phone is not usable because it wont restore. What do I do?

    Something in your backup may be corrupt. Try wiping it and setting it up as a new device, then sync your apps, data and media back to it from iTunes. DO NOT resotre from your backup. If the problem is contained in the backup, it will bring it right back again if you restore.

  • I just replaced my hard drive and am trying to install the Snow Leppard OS on my Mac mini using the DVD's that came with the unit. Is there a step by step procedure that will guide me through this process?

    I just replaced my hard drive due to failure in my Mac mini. I am trying to load the Snow Leppard OS from the DVD's that came with the unit. Is there a step-by-step procedure somewhere that would help me? This is my first problem with my first Mac. I thought getting to the hard drive and changing it would be the hard part but I made it through that with little trouble. My lack of software experience on the Mac is really slowing me down. I believe I'm not making the right choices in the Disk Utility program.Any help would be greatly appreciated. Thank you.

    Prep the new drive:
    Drive Preparation
    1.  Boot from your OS X Installer Disc. After the installer loads select your language and click on the Continue button.  When the menu bar appears select Disk Utility from the Utilities menu.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  SMART info will not be reported  on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Upon completion quit DU and return to the installer. Install OS X. When the installation has completed you can proceed to restore your data from your backups. If you have an existing backup from Time Machine or another hard drive then upon completing the Setup Assistant you will have an option to restore from another Mac, a TM backup, or another drive. Use the appropriate option.

  • My iphone 5 will not turn on and i connect it to the charger and the logo strats blinking what can i do or what is wrong?

    my iphone 5 has stop working it turnd off and it wont turn on i connect it to the charger and the logo strats blinking but it wont turn on, what can i do or what is wrong

    First try a Reset  ( No Data will be Lost )
    Press and hold the Sleep/Wake button and the Home button at the same time for at least Ten seconds... (But can take Longer)... until the Apple logo appears. Release the Buttons
    If no joy... Try a Restore...
    1: Connect the device to Your computer and open iTunes.
    2: If the device appears in iTunes, select and click Restore on the Summary pane.
    3: If the device doesn't appear in iTunes, try using the Steps in this article to force the device into Recovery Mode.
    From Here
    http://support.apple.com/kb/TS3281
    Make sure you have the Latest Version of iTunes (v11) Installed on your computer
    iTunes free download from www.itunes.com/download
    Note on Recovery Mode.
    You may need to try this More than Once... Be sure to Follow ALL the Steps...
    Once you have Recovered your Device...
    Re-Sync your Content or Restore from the most Recent Backup...
    Restore from Backup  >  http://support.apple.com/kb/ht1766

Maybe you are looking for

  • Report model - number of values selected in DDL param

    Good afternoon, I have created a report model that references Teradata views, and I am using this model to populate several datasets in a Report Builder report.  One dataset returns actual results, and the other datasets are used to populate availabl

  • OnAlarm/wait thread count configuration in BPEL

    BPEL 10g, We have a com.oracle.bpel.expirationAgent.threadCount property to set the thread count for OnAlarm/wait. ORACLE_HOME/bpel/domain/DOMAIN_NAME/config/resources-quartz.properties. BPEL 11g, Can you please point me the configuration file to set

  • Microsoft outlook messages blank

    I am on a committee that gets meeting notifications by email.  The moderator uses MS Outlook to send invitations (accept/decline).  All I see is the subject line.  There is no body text and no attachments. I use Mail.

  • Multi Camera Troubleshooting help

    I am having trouble getting my Multi camera editing to line the clips up with the audio.  I have one of the tracks sync to good audio. All the other tracks have audio, i have the sync audio selected but Multi camera tracks sync to the head and don't

  • If you need ANY kind of help with your Zen Vision:M or any other Creative prod

    I just wanted to let everyone know there's a great website and forum where you can find really helpfull things related to all Creative products. It really helped me with my Zen Vision:M There you'll find news, deals, info, help, etc. and the forum I