I am trying to create the store procedure but it is returning the following error what can I do.

USE [PHPExtracts]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pr_Extract_wt_569_OPTUM]') AND type in (N'P', N'PC'))
BEGIN
DROP PROCEDURE [dbo].[pr_Extract_wt_569_OPTUM]
PRINT '--- Procedure [dbo].[pr_Extract_wt_569_OPTUM] dropped ---'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Brian Peterson>
-- Create date: <02/25/2014>
-- Description: <This Stored Procedure populates
-- staging table with Facets Member data
-- for Groups 100108,100115,105519,100398,106528,108601>
-- =============================================
CREATE PROCEDURE [dbo].[pr_Extract_wt_569_OPTUM]
AS
BEGIN
SET NOCOUNT ON;
declare @lastRunDate datetime
declare @currentRunDate datetime
-- RETRIEVE last run date
SET @lastRunDate = (select CONVERT(datetime,CHAR_CFLD1) from Extracts_Common_Table
where EXTRACT_ID=569 and SEQ_NO=1 AND DOMAIN_NAME ='LastRunDate'
AND Active=1)
-- if the @lastRunDate is null, then set the date to the default MEPE_EFF_DT
IF @lastRunDate IS NULL
SET @lastRunDate = '01-01-1920'
-- SET current run date
SET @currentRunDate = GETDATE()
PRINT @lastRunDate
PRINT @currentRunDate
-- CHECK for running on same date and exit if true
IF DATEDIFF(dayofyear, @lastRunDate, @currentRunDate) > 0
BEGIN
PRINT 'Deleting tables...'
TRUNCATE TABLE Extract_wt_569_OPTUM
PRINT 'Inserting new Current data...'
-- INSERT statements for procedure here
Insert into [dbo].[Extract_wt_569_OPTUM]
([DATESORT]
,[MEMBERNUMBER]
,[LASTNAME]
,[FIRSTNAME]
,[MIDDLENAME]
,[GENDER]
,[DOB]
,[DatePolicyEffective]
,[RELATIONTOINSURED]
,[SSN]
,[DateEffective]
,[DateExpiration]
,[SUBSCRIBER_ID]
,[ALTERNATE_ID]
,[ADDRESS1]
,[ADDRESS2]
,[ADDRESS3]
,[CITY]
,[STATE]
,[ZIP CODE]
,[TELEPHONE]
,[GROUP_NO]
,[GROUPNAME]
,[LINEOFBUSINESS]
,[PRODUCT_TYPE])
-- add wt_569 columns
-- add select here
SELECT top 1000 ---- remove top 1000 when loading
null as "DATESORT"
,convert(varchar,rtrim(sbsb.SBSB_ID)) + right('000' + rtrim(convert(varchar,meme.MEME_SFX)), 3) as "MEMBERNUMBER"
,meme.MEME_LAST_NAME as "LASTNAME"
,meme.MEME_FIRST_NAME as "FIRSTNAME"
,meme.MEME_MID_INIT as "MIDDLENAME"
,meme.MEME_SEX as "GENDER"
,replace(CONVERT(varchar(10),meme.MEME_BIRTH_DT,110),'-','') as "DOB"
,replace(CONVERT(varchar(10),meme.MEME_ORIG_EFF_DT,110),'-','') as "DatePolicyEffective"
,case
When meme.MCRL_MEME_CREL_CD = 'M' Then 18 -----Added case statement for RELATIONTOINSURED by Andrew 08/19/2014
When meme.MCRL_MEME_CREL_CD = 'O' Then 34
When meme.MCRL_MEME_CREL_CD = 'W' or meme.MCRL_MEME_CREL_CD = 'H' Then 01
When meme.MCRL_MEME_CREL_CD = 'S' or meme.MCRL_MEME_CREL_CD = 'D' Then 19
END
as "RELATIONTOINSURED"
,case when ltrim(rtrim(meme.MEME_SSN)) = '' THEN '999999999'
else ltrim(rtrim(meme.MEME_SSN)) end as "SSN"
,replace(CONVERT(varchar(10),mepe.MEPE_EFF_DT,110),'-','') as "DateEffective"
,replace(CONVERT(varchar(10),mepe.MEPE_TERM_DT,110),'-','') as "DateExpiration"
,sbsb.SBSB_ID as "SUBSCRIBER_ID"
,null as "ALTERNATE_ID"
,sbad.SBAD_ADDR1 as "ADDRESS1"
,sbad.SBAD_ADDR2 as "ADDRESS2"
,sbad.SBAD_ADDR3 as "ADDRESS3"
,sbad.SBAD_CITY as "CITY"
,sbad.SBAD_STATE as "STATE"
,sbad.SBAD_ZIP as "ZIP CODE"
,sbad.SBAD_PHONE as "TELEPHONE"
,grgr.GRGR_ID as "GROUP_NO"
,grgr.GRGR_NAME as "GROUPNAME"
,pdpd.LOBD_ID as "LINEOFBUSINESS"
,mctr.MCTR_DESC as "PRODUCT_TYPE"
-----,null as "BENEFIT_LEVEL" Dropped Benefit_Level not required
FROM [FacetsReport].[dbo].[CMC_MEME_MEMBER] meme with (NOLOCK)
JOIN [FacetsReport].[dbo].[CMC_SBSB_SUBSC] sbsb with (NOLOCK) on meme.SBSB_CK = sbsb.SBSB_CK
JOIN [FacetsReport].[dbo].[CMC_SBAD_ADDR] sbad with (NOLOCK) on meme.SBSB_CK = sbad.SBSB_CK and meme.SBAD_TYPE_MAIL = sbad.SBAD_TYPE
JOIN [FacetsReport].[dbo].[CMC_MEPE_PRCS_ELIG] mepe with (NOLOCK) on meme.MEME_CK = mepe.MEME_CK
JOIN [FacetsReport].[dbo].[CMC_GRGR_GROUP] grgr with (NOLOCK) on meme.GRGR_CK = grgr.GRGR_CK
JOIN [FacetsReport].[dbo].[CMC_PDPD_PRODUCT] pdpd with (NOLOCK) on mepe.PDPD_ID = pdpd.PDPD_ID
JOIN [FacetsReport].[dbo].[CMC_PDDS_PROD_DESC] pdds with (NOLOCK) on pdds.PDPD_ID = pdpd.PDPD_ID
JOIN [FacetsReport].[dbo].[CMC_MCTR_CD_TRANS] mctr with (NOLOCK) on mctr.MCTR_VALUE = pdds.PDDS_MCTR_BCAT
--JOIN [FacetsReport].[dbo].[CMC_CSCS_CLASS] cscs with (NOLOCK) on cscs.PDPD_ID = pdpd.PDPD_ID
WHERE mepe.MEPE_ELIG_IND = 'Y'
AND DATEDIFF(day, mepe.MEPE_EFF_DT, @StartDate) >= 0
AND DATEDIFF(day, mepe.MEPE_TERM_DT, @RunDate) <= 0
--UPDATE the run date
PRINT 'Updating LastRunDate...'
update Extracts_Common_Table set CHAR_CFLD1= @currentRunDate where EXTRACT_ID=569 and SEQ_NO=1 AND
DOMAIN_NAME ='LastRunDate' AND Active=1
END -- Same Date Run Check
END
GO
PRINT '------- Procedure [dbo].[pr_Extract_wt_569_OPTUM] Created ----------'
GRANT EXECUTE ON [dbo].[pr_Extract_wt_569_OPTUM] TO [public] AS [dbo]
GO
Message error:
Msg 102, Level 15, State 1, Procedure pr_Extract_wt_569_OPTUM, Line 71
Incorrect syntax near ')'.
Msg 137, Level 15, State 2, Procedure pr_Extract_wt_569_OPTUM, Line 118
Must declare the scalar variable "@StartDate".
------- Procedure [dbo].[pr_Extract_wt_569_OPTUM] Created ----------
Msg 15151, Level 16, State 1, Line 4
Cannot find the object 'pr_Extract_wt_569_OPTUM', because it does not exist or you do not have permission.

Shouldn't @StartDate be an input parameter to the stored procedure? @RunDate also?
Example for sp with parameters:
http://www.sqlusa.com/bestpractices2008/stored-procedure-parameters/
The last error will go away upon a successful sp compile.
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Similar Messages

  • I just got a new iPhone 4S and tried to restore but it didn't finished downloading all the apps, tried to reset and restore again, but it wouldn't start over. What can I do?

    I just got a new iPhone 4S and tried to restore but it didn't finished downloading all the apps, tried to reset and restore again, but it wouldn't start over. What can I do?

    http://support.apple.com/kb/ts3694
    Check USB connections
    If there’s an issue with the USB port, cable, dock, or hub, or if the device becomes disconnected during restore, try troubleshooting the USB connection, then troubleshooting your security software.
    Common errors: 13, 14, 1600-1629, 1643-1650, 2000-2009, 4000, 4005, 4013, 4014, 4016, “invalid response”, and being prompted to restore again after a restore completes.
    To narrow down the issue, you can also change up your hardware:
    Use another USB cable.
    Plug your cable into a different USB port on your computer.
    Try a different dock connector (or no dock).
    Add (or remove) a USB hub between your device and computer.
    Connect your computer directly to your Internet source, with no routers, hubs, or switches.
    If you see your error after changing your USB connections, continue to the next section to troubleshoot your hardware.

  • HT1338 I begin to download mountain lion update and it fail. Then I tried again and icon shows "waiting" but it never begin to download. What can I do?

    I begin to download mountain lion update and it fail. Then I tried again and icon shows "waiting" but it never begin to download. What can I do?

    RainbowGarner wrote:
    By install i presume you mean add it to the bottom of the machine ?
    Yes, and it's rather easy to do too.
    Your machine has two slots. These are the specs for a 2008 iMac (if your machine is different then check with Crucial.com and they will match the correct RAM for your machine)
    Maximum Memory
    6.0 GB (Actual) 4.0 GB (Apple)
    Memory Slots
    2 - 200-pin PC2-6400 (800MHz) DDR2 SO-DIMM
    So all you need to do is visit Crucial.com or OtherWorld Computing to order it, and OtherWorld Computing has install videos.
    Here is one on YouTube. Easy pleasy.
    Just make sure to discharge any static electricity and not touch the contacts, just the plastic edges.
    https://www.youtube.com/watch?v=Fb_B3K1Za5Y

  • How do I reeve the TomTom application from my MacPro Notebook. Application continues to run and will not stop. I bought a Tom Tom GPS and installed the connect app but decided to return the GPS. There seems to be no way to remove the software.

    How do I remove the TomTom GPS software from my MacPro. I bought the GPS and began to install the software but decided to return the GPS. The software will not delete and continues to run trying to connect to the GO 60. I have 10.9.5 OS.
    Tanks to anyone who may help.

    Hi ..
    Follow the instructions here >  How To Completely Uninstall Software under Mac OS X

  • HT203200 I HAVE JUST PURCHASED LES MISERABLES FROM THE STORE AND TWO TRACKS DID NOT DOWN LOAD. WHAT CAN I DO AND CAN I GET A REFUND FROM THE STORE OR DELETE ALBUM AND GET THE STORE TO DOWNLOAD AGAIN

    I HAVE JUST PURCHASED LES MISERABLES FROM THE STORE BUT TWO TRACKS DID NOT DOWNLOAD. CAN I GET ANOTHER DOWNLOAD FROM THE STORE OR A REFUND? ALTERNATIVELY CAN I DOWNLOAD THE WHOLE ALBUM AGAIN FREE?

    Try the Store tab in iTunes and Check for Downloads.
    If that doesn't work go to the main itunes store screen in itunes and on teh right side under quick links see if you have a purchased secrion - do the tracks appear there for download?
    Failing that contact support:
    http://www.apple.com/support/itunes/store/

  • I am trying to create a new acct but i keep on getting an error message saying that i already have a

    an account. This is the first time i use this site.

    Hi John,
    You might have better luck posting this in the library feedback forum here:
    http://social.msdn.microsoft.com/Forums/en-us/home?forum=libraryfeedback&filter=alltypes&sort=lastpostdesc
    It seems odd to me that the TechNet library feedback forum lives under the MSDN branding, but that seems to be the case.
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • Firefox crashes loading youtube videos but only there. it's working on other video pages. i started it in a safed modus but the problem is still there. I reinstalled firefox and the flash pluggin but it didn't help anything. What can I try else?

    I'm using firefox 3.6.8.
    All my pluggins are up to date
    Using a link to a youtube video or on youtube itself the page crashes. I only can hear the sound for some seconds, then that stopps too. I have to close firefox using taskmanager, nothing else is working anymore.

    Thanks again for your help.
    I did these two updates now (java and plugin) and tried some youtube videos. At the beginning I thoughts that it is working now, because normally firefox crashed already with the first or second video. Now it's working for 5-10 videos and only every 5th-10th video brings firefox to crash.
    With the plugin-container process thing I'm not really sure what to do. Do I have to disable the crash protection? (the 4 things that are written for window?) Could you maybe help me with this again?

  • Google chat will not load nor will the graphics on all the web pages but it works ok in other browsers, what can I do to fix this?

    utube vids play but the (pics) graphics do not load on any web page I go to and my google chat says it can't connect to internet but my internet works fine and google chrome works fine too. and google mail graphic buttons for email are not appearing also.

    If images are missing then check that you do not block images from some domains.
    *Press the F10 key or tap the Alt key to bring up the hidden Menu bar.
    Check the permissions for the domain in the currently selected tab in "Tools > Page Info > Permissions"
    Check "Tools > Page Info > Media" for blocked images
    *Select the first image link and use the cursor Down key to scroll through the list.
    *If an image in the list is grayed and "<i>Block Images from...</i>" has a checkmark then remove this checkmark to unblock images from this domain.
    Make sure that you do not block (third-party) images, the <b>permissions.default.image</b> pref on the <b>about:config</b> page should be 1.
    Make sure that you haven't enabled a High Contrast theme in the Windows/Mac Accessibility settings.
    Make sure that you allow pages to choose their own colors.
    *Tools > Options > Content : Fonts & Colors > Colors : [X] "Allow pages to choose their own colors, instead of my selections above"
    Note that these settings affect background images.
    See also:
    *http://kb.mozillazine.org/Website_colors_are_wrong
    There are extensions like Adblock Plus (Firefox/Tools > Add-ons > Extensions) and security software (firewall, anti-virus) that can block images and other content.
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    *http://kb.mozillazine.org/Images_or_animations_do_not_load
    *http://kb.mozillazine.org/Websites_look_wrong

  • I have a new i pad, but when I first open it is not showing the standard icon, but, show me an i Tunes icon, what can I do?

    Does somebody can let me know anything?

    Make sure you have the latest iTunes on your computer. Plug your iPad into your computer and open iTunes. Let htem initialize and iTunes will talk you through starting up your ipad.
    and then i'd download and read the manual
    http://support.apple.com/manuals/

  • Trying to send messges via SMS but it sends it via iMessage. What can I do?

    My friend has a iPhone with no data bit he has iMessage linked to his mobile number. When I try to text him via SMS it sends it via iMessage. How can I change this without shutting off iMessage?

    Thank you so much!!! I got my iPhone today and I was Afraid I would have problems texting my friends but u solved it! Thanks so much again! :)

  • Living in Dubai where many apps are blocked. How can I get around ? Tried to create a new Id but my billing address in Dubai will not match the criteria for an account in the US. Help please to get around the censorship...thnaks

    Living in Dubai where many apps are blocked. How can I get around ? Tried to create a new Id but my billing address in Dubai will not match the criteria for an account in the US. Help please to get around the censorship...thanks

    The censorship in regards to certain apps not being available in your country is by your country, not by Apple.
    Due to various laws and licensing in each country, in order to have an iTunes store account in a particular country you must have a credit card with a billing address in that country. If this were up to Apple, there would be no such requirement and there would be only one iTunes store for the entire world, but various laws, regulations, and licensing issues in each country, this is required by Apple.

  • HT2589 I am trying to create a new account but every time I put in my billing information and numbers, the same screen pops up with, in red "For assistance contact iTunes Support". I am currently overseas and want my imessage to work correctly

    I am trying to create a new account but every time I put in my billing information and numbers, the same screen pops up with, in red "For assistance contact iTunes Support". I am currently overseas and want my imessage to work correctly

    to contact iTunes store support, follow these steps:
    1. Go to expresslane.apple.com
    2. select 'itunes' and then 'itunes store'
    3. select a topic and a subject
    4. click 'continue' and then 'email'
    5. fill out the form and explain your situation
    6. they will respond within 24 hours usually
    Good luck

  • Get the body of the store procedure

    Hi All,
    THe store procedure is created successfully and I don't know how to get the definition of the store procedure. In MSSQL server I used "sp_helptext <store procedure name>" but I don't know how to get text(description) of the store procedure in ORACLE. Your help is greatly appreciated.
    Thanks,
    JP

    Hi all,
    I ran the following statement to get the body of the store procedure:
    select text from user_source where name = <store procedure>
    and the long text(body of store procedure) is returned back. This store procedure is created with the error message return back as "Warning: Procedure created with compilation errors". So I were wondering why the store procdure is in user_source although the creation of this store procedure is returned an error message as mentioned above. Is there anyway that we can find out if the store procedure is created with the compilation errors.
    Thanks,
    JP

  • Oracle JBDC error while calling the store procedure

    HI All,
    I am get one strange error while calling a store procedure which has two parameter in and out.
    I am pass the correct XML file which reaches the RDB and then PI receives a exception error message saying:
    oracle.rdb.jdbc.common.RdbException: Closed Resultset
    where as no error log is availble in RBD for the same.
    Can anybody tell me what can be the cause of the error.
    Let me know if you requires more information on this.
    -adi

    Hi Kiran,
    Thanks..
    But I am not able to understand you. I am calling a store procedure not a table. and we not doing anything in the store procedure except return one constant value in Out parameter.
    -Adi

  • I want to create an account in USA store, I activate a paypal account and when I validate the pay form send me an error, what can I do?

    I want to create an account in USA store, I activate a paypal account and when I validate the pay form send me an error, what can I do?

    Are you in the U.S?
    You can only buy from the itunes store of your country of residence ( verified by valid billing address on your payment info) and ONLY while inside the borders of that country.

Maybe you are looking for

  • HT1349 i keep downloading the new itunes and it isn't updating on my pc

    I am in my itunes and it keeps telling me there are updates.  I've download the new version twice and for some reason it doesn't end up updated.  help?

  • Router as range extender????

    I was told that I could use this router (EA4500) as a range extender for my Uverse service. To do this, do I need to set it up in bridge mode? I'm a novice at this & I'm not sure what I'm doing. Does the router have to remain plugged in to the modem

  • Newbie with Photo Elements 8

    I have used Adobe's photo management programs for years but Photo Elements is the most mysterious of them all. I have two questions at this point and may have moer later.  Hope someone has the answers. a) How do I get the Timeline to appear at the to

  • FTP from a Servlet

    I need to start an ftp tranfer from a servlet. How can I do?

  • [ID CS2 Mac]Please tell me the Suitable IDE?

    Hi all, I want to develop a plug in InDesign CS2 on Mac 10.5 . I have downloaded this SDK :Adobe InDesign CS2 4.0.2 Products SDK. I read the Readme.txt & found that the IDE for developing a plugin on Mac is Metrowreks CodeWarrior 9.3 . Right now ther