Creating a Job for publication in Sql Server with select statement for passing a parameter

I am creating a job for adding article to a publication.  the second step (e.g. for adding article) gives me error. I pass the name of the table as follow:
     EXEC sp_addarticle
           @publication = 'TTB', --THE NAME OF MY PUBLICATION
           'select top (1)' @article = 'Name from TableAdded Order by create_date Desc',
           'select top (1)' @source_object = 'Name from TableAdded Order by create_date Desc',
            @force_invalidate_snapshot = 1;
TableAdded is a table I have in my publisher which contains the name of the newly added table.
I believe it fails because the way I pass the name of the article to the store procedure is not correct. Can anyone please help me on that?
Kind regards
Amin

Yes, the way you add article is wrong.
you may try the below and let us know if you have any issues:
while loop begin (Get the values from TableAdded with status IsAdded=0)
          Assign the values to variables like @article = Select top 1 Name from TableAdded where IsAdded=0
          Call the sp_addarticle assigning the variable
          update the Isadded flag in tableAdded for the name to 1 
 end while 
BTB, Article configuration is supposed to be a one time configuration. Having said, you can easily configure through API. Caution, not sure what are you trying here, for adding new article, you may need to synch the data first in the above approach and should
carried out in the downtime.

Similar Messages

  • SQL insert with select statement having strange results

    So I have the below sql (edited a bit). Now here's the problem.
    I can run the select statement just fine, i get 48 rows back. When I run with the insert statement, a total of 9062 rows are inserted. What gives?
    <SQL>
    INSERT INTO mars_aes_data
    (rpt_id, shpdt, blno, stt, shpr_nad, branch_tableS, csgn_nad,
    csgnnm1, foreign_code, pnt_des, des, eccn_no, entity_no,
    odtc_cert_ind, dep_date, equipment_no, haz_flag, schd_no,
    schd_desc, rec_value, iso_ulti_dest, odtc_exempt, itn,
    liscence_no, liscence_flag, liscence_code, mblno, mot,
    cntry_load, pnt_load, origin_state, airline_prefix, qty1, qty2,
    ref_val, related, routed_flag, scac, odtc_indicator, seal_no,
    line_no, port_export, port_unlading, shipnum, shprnm1, veh_title,
    total_value, odtc_cat_code, unit1, unit2)
    SELECT 49, schemaP.tableS.shpdt, schemaP.tableS.blno,
    schemaP.tableS.stt, schemaP.tableS.shpr_nad,
    schemaP.tableM.branch_tableS, schemaP.tableS.csgn_nad,
    schemaP.tableS.csgnnm1, schemaP.tableD.foreign_code,
    schemaP.tableS.pnt_des, schemaP.tableS.des,
    schemaP.tableD.eccn_no, schemaP.tableN.entity_no,
    schemaP.tableD.odtc_cert_ind, schemaP.tableM.dep_date,
    schemaP.tableM.equipment_no, schemaP.tableM.haz_flag,
    schemaP.tableD.schd_no, schemaP.tableD.schd_desc,
    schemaP.tableD.rec_value,
    schemaP.tableM.iso_ulti_dest,
    schemaP.tableD.odtc_exempt, schemaP.tableM.itn,
    schemaP.tableD.liscence_no,
    schemaP.tableM.liscence_flag,
    schemaP.tableD.liscence_code, schemaP.tableS.mblno,
    schemaP.tableM.mot, schemaP.tableS.cntry_load,
    schemaP.tableS.pnt_load, schemaP.tableM.origin_state,
    schemaP.tableM.airline_prefix, schemaP.tableD.qty1,
    schemaP.tableD.qty2,
    schemaC.func_getRefs@link (schemaP.tableS.ptt, 'ZYX'),
    schemaP.tableM.related, schemaP.tableM.routed_flag,
    schemaP.tableM.scac, schemaP.tableD.odtc_indicator,
    schemaP.tableM.seal_no, schemaP.tableD.line_no,
    schemaP.tableM.port_export,
    schemaP.tableM.port_unlading, schemaP.tableS.shipnum,
    schemaP.tableS.shprnm1, schemaP.tableV.veh_title,
    schemaP.tableM.total_value,
    schemaP.tableD.odtc_cat_code, schemaP.tableD.unit1,
    schemaP.tableD.unit2
    FROM schemaP.tableD@link,
    schemaP.tableM@link,
    schemaP.tableN@link,
    schemaP.tableS@link,
    schemaP.tableV@link
    WHERE tableM.answer IN ('123', '456')
    AND SUBSTR (tableS.area, 1, 1) IN ('A', 'S')
    AND entity_no IN
    ('A',
    'B',
    'C',
    'D',
    'E',
    AND TO_DATE (SUBSTR (tableM.time_stamp, 1, 8), 'YYYYMMDD')
    BETWEEN '01-Mar-2009'
    AND '31-Mar-2009'
    AND tableN.shipment= tableD.shipment(+)
    AND tableN.shipment= tableS.shipnum
    AND tableN.shipment= tableM.shipment(+)
    AND tableN.shipment= tableV.shipment(+)
    <SQL>
    Edited by: user11263048 on Jun 12, 2009 7:23 AM
    Edited by: user11263048 on Jun 12, 2009 7:27 AM

    Can you change this:
    BETWEEN '01-Mar-2009'
    AND '31-Mar-2009'To this:
    BETWEEN TO_DATE('01-Mar-2009', 'DD-MON-YYYY')
    AND TO_DATE('31-Mar-2009','DD-MON-YYYY')That may make no difference but you should never rely on implicit conversions like that, they're always likely to cause you nasty surprises.
    If you're still getting the discrepancy, instead of and INSERT-SELECT, can you try a CREATE TABLE AS SELECT... just to see if you get the same result.

  • Job Manger configuration when SQL Server Data base is used

    Hi All,
    I have worked on starting scheduler services after job manager configuration  and created ibots.
    But now we are using SQL Server.
    In this case we are facing a problem while configuring job manager.
    In SQL Server we will be having 2 types of authentication.
    Windows authentication and SQL Server Authentication.
    When we use both types of authentication in the job manager I am getting an error in the log files regarding authentication (NT Authentication Failed)
    Can any one tell me what type authentication should be used for scheduling
    Thanks
    Subhash

    Hi this problem solved
    Like to say I have recreated a dsn and gave sql server authentication which worked for me.
    My question is can we get uding windows authentication or only sql server works??
    Can I have some solution for that
    My thought if sql server authentication  works then this should also work???
    Thanks
    Subhash

  • [Forum FAQ] How do I create calculated measure using AMO in SQL Server Analysis Services?

    Introduction
    In SQL Server Analysis Services (SSAS), you can create a calculated measure in SQL Server Data Tool (SSDT)/Boniness Integrated Development Studio (BIDS). Sometimes you may need to create calculated measure by using AMO in a C# or VB project.
    In this article, I will demonstrate so how to create calculated measure using AMO in SSAS?
    Prerequisites
    Before create calculated measure using AMO, you need to ensure that the following components were installed in your server.
    The multidimensional database AdventureWorks Multidimensional Model 2012
    A SQL Server with SSIS and SSAS installed
    The AMO libraries installed:
    X86 Package (SQL_AS_AMO.msi)
    X64 Package (SQL_AS_AMO.msi)
    Solution
    Here is the detail steps to create calculated measure using AMO in SSAS.
    Open SSDT and create a new SSIS project.
    Drag Script Task to the design surface.
    Click SSIS-> Variables to open the Variables window and add two variables that used to connect to the server and database.
    Create a connection to connect to SSAS server.
    Rename the connection name to ssas.
    Double click the Script Task to open Script Task Editor.
    Add Connection and Database variables to ReadWriteVariables textbox and then click Edit Script button.
    Add AMO reference in the Solution Explore window.
    Copy the script below and paste it into the script.
    Dim objServer As Server
    Dim objDatabase As Database
    Dim strDataBaseID As String
    Dim objCube As Cube
    Dim objMdxScript As MdxScript
    Dim objCommand As Command
    Dim strCommand As String
    objServer = New Server
    objServer.Connect("localhost")
    objDatabase = objServer.Databases("AdventureWorksDW2012Multidimensional-EE2")
    strDataBaseID = objDatabase.ID
    If objDatabase.Cubes.Count > 0 Then
    objCube = objDatabase.Cubes("Adventure Works")
    If objCube.MdxScripts.Count > 0 Then
    objMdxScript = objCube.MdxScripts("MdxScript")
    objMdxScript = objCube.MdxScripts(0)
    Else
    objCube.MdxScripts.Add("MdxScript", "MdxScript")
    objMdxScript = objCube.MdxScripts("MdxScript")
    End If
    objCommand = New Command
    strCommand = "CREATE MEMBER CURRENTCUBE.[Measures].[Multipy Measures By 3]"
    strCommand = strCommand & " AS [Measures].[Internet Sales Amount] * 3, "
    strCommand = strCommand & " VISIBLE = 1 ; "
    objCommand.Text = strCommand
    objMdxScript.Commands.Add(objCommand)
    objMdxScript.Update()
    objCube.Update()
    End If
    objServer.Disconnect()
    Then you can run this SSIS package to create the calculated measure.
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thanks,
    Is this a supported scenario, or does it use unsupported features?
    For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
    in a supported way?
    Thanks! Josh

  • How to create database link between oracle and SQL Server

    Hello Everyone,
    Here i have Oracle Database 9i and SQL Server 2005 databases.
    I have some tables in sql server db and i want to access from Oracle.
    How to create a database link between these two servers
    Thanks,

    Thanks for Everyone,
    I was struggle with this almost 10 days....
    I created Database link from Oracle to SQL Server
    Now it is fine.........
    Here i am giving my servers configuration and proceedure how i created the db link...@
    Using Generic Connectivity (HSODBC) we can create db link between Oracle and SQL server.
    Machine (1)
    DB Version : Oracle 9.2.0.7.0
    Operating System : HP-UX Itanuim 64 11.23
    IP : 192.168.0.31
    Host : abcdbt
    Machine (2)
    Version : SQL Server 2005
    Operating System : Windows server 2003 x86
    IP : 192.168.0.175
    Host : SQLDEV1
    User/PW : sa/abc@123! (Connect to database)
    Database : SQLTEST (exsisting)
    Table : T (“ T “ is the table existing in SQLTEST database with 10 rows)
    Prerequisites in Machine (2):
    a)     Oracle 10g software
    b)     User account to access SQL Server database (sa/abc@123!)
    c)     Existing SQL Server Database (SQLTEST)
    d) Tables (testing purpose) (T)
    Steps:
    1)     Install Oracle 10.2.0.1 (Only SW,No need of database) *(Machine 2)*
    2)     Create a DSN where your windows Oracle 10g SW resides *(Machine 2)*
    Control panel >> Administrative Tools >> Data Source (ODBC) >> System DSN ADD
    You can follow this link also.....
    http://www.databasejournal.com/features/oracle/article.php/3442661/Making-a-Connection-from-Oracle-to-SQL-Server.htm
    I created DSN as
    DSN name : SQLTEST
    User : SA/abc@123! (Existing user account)
    Host : 192.168.0.175 (machine 2)
    Already I have 1 database in SQL Server with the name SQLTEST
    You can create DSN with different name also (not same as db name also)
    3)     Create a hsodbc init file in $ORACLE_HOME\hs\admin *(Machine 2)*
    Create init<DSN NAME> file
    Ex: initSQLTEST
    Copy inithsodbc to initSQLTEST
    And edit
    initSQLTEST file
    HS_FDS_CONNECT_INFO = SQLTEST    <DSN NAME>*
    HS_FDS_TRACE_LEVEL = OFF*
    save the file....@
    4)     Configure Listener.ora *(Machine 2)*
    LISTENER_NEW =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.175)(PORT = 1525))
    SID_LIST_LISTENER_NEW =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = SQLTEST) *+< Here SQLTEST is DSN NAME >+*
    (ORACLE_HOME = G:\oracle 10g\oracle\product\10.2.0\db_1)
    (PROGRAM = hsodbc))
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = G:\oracle 10g\oracle\product\10.2.0\db_1)
    (PROGRAM = extproc) )
    :> lsnrctl start LISTENER_NEW
    5)     Configure tnsname.ora *(Machine 2)*
    SQLTEST11 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.175)(PORT = 1525))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = SQLTEST))
    (HS=OK)
    :> tnsping SQLTEST11
    If No errors then conti….
    6)     Configure a file *(Machine 1)*
    Cd $TNS_ADMIN ($ORACLE_HOME/network/admin)
    Create a file
    $ vi TEST_abcdbt_ifile.ora
    something=
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST =192.168.0.175) (PORT=1525))
    (CONNECT_DATA=
    (SID=SQLTEST))
    (HS=OK)
    $ tnsping something
    $ sqlplus system/manager
    Your connected to Oracle database *(machine 1)*
    create database link xyz connect to “sa” identified by “abc@123!” using ‘SOMETHING’;
    select * from t@xyz;10 rows selected.
    Thanks,
    Edited by: ram5424 on Feb 10, 2010 7:24 PM

  • How to create database link from oracle to sql server

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal
    Hi Vishal,
    I found a lof of information regarding how to create a database link from Oracle to SQL Server, please see:
    https://www.google.co.in/?gws_rd=cr&ei=vd3XUvGFO8TgkAXqlYCADg#q=how+to+create+database+link+from+oracle+to+sql+server
    We discuss SQL Server related issue in this forum. If you have any more question regarding Oracle, please post it in Oracle communities forum for better support.
    Regards,
    Elvis Long
    TechNet Community Support

  • Creating a job for a procedure with an input parameter

    Hi,
    I want to create a job for a procedure ( sp_proc ) with a input parameter.
    The input parameter is a date value.
    As per the syntax for dbms_job.submit procedure;
    dbms_job.submit (
    job IN BINARY_INTEGER,
    what IN VARCHAR2,
    next_date IN DATE,
    interval IN VARCHAR2 DEFAULT 'NULL',
    no_parse IN BOOLEAN DEFAULT FALSE);
    How should the procedure be declared in the 'what' parameter of the dbms_job.submit procedure ?
    Please guide.
    Thanks.

    Hi,
    You are wright, I have found this thread [DBMS_JOB -- how to pass parameters to the job|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:351033761220].
    Regards,

  • How to create Background job for Dialog program

    Hi Experts,
    I have copied Standard tcode to Z-tcode (CS12 tcode).
    Now my requirement is to create background job for this program (but program is not a 'E' type its 'I').
    How we can schedule Dialog program to Background.
    Pls suggest me.
    Regards
    SK

    Hi do as below :
    Reefer below :
    Bakcground Job Creation
    You will have to submit your report using Submit statement ,
    then inside the submitted report write open_job.
    Regards,
    Uma

  • Does Create as table command  works in sql server

    Hi friends,
    does Create as table command works in sql server,if yes pls help me with syntax

    > does Create as table command works in sql server,if
    yes pls help me with syntax
    Just out of interest, what is it supposed to do? There is no "CREATE AS TABLE" command in Oracle.

  • How to create a job for proces chain

    Hi All,
    I have a process chain that gets a trigger (.txt Trigger file) in AL11 inbound foulder.....
    we will check for the same trigger in AL11...if it is available..we will trigger the chain using sm64 ...
    now, i want to create a job for the same and schedule it automatically everyday.....
    Any help will be appreciated....

    Dear Sam2027,
    you can set a "recurrence" within the schedule options where you can decide not only the day but also the time.
    The recurrence can also be use in conjunction with your trigger .txt (which I believe it's a file event): in this case both of them need to be satisfied in order for your schedule to run.
    I hope this will help.
    Regards,
    Samanta

  • Oracle equivalent for MS Sql Server WITH(NOLOCK)

    Hi all :-)
    What is the equivalent of MS Sql Server WITH(NOLOCK)
    hint in Oracle ... or ... how can I achieve the same
    effect in Oracle SELECT queries ?

    = dirty read .
    to the op : read the concepts guide before going further; Oracle implements a different concurrency model than SQL Server

  • Deploy sql server with scvmm 2012 r2

    Hello,
    How to deploy SQL Server with scvmm such a way that  I get a VM with OS+ SQL installed.
    Is there way that i will get installed SQL with all feature to create new VM.
    I have followed the steps as given links    http://blog.islamgomaa.com/?p=236 
    I worked but when i have create a VM , still I need to installed SQL management Stdio  manually for create DBs.

    MSFT has also built SQL Server Service Templates that will do this for you - you download the template, add your OS disk, add the SQL install media and go.
    Here is how to get the MSFT built templates:
    http://blogs.technet.com/b/scvmm/archive/2013/11/04/using-the-service-models-web-platform-installer-gallery.aspx
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

  • Sql server with multiple instance

    hi  All,
    i want  to  install sql server with two instance   and i want  to assign two  separate is  ips   for  both   default instance  and named  instance   and  both   should  work like
    two different server
    note:  If i  logged  with  one  ip(default instance)   it should  show  its  own  databases  not both or  named   instance  databases
    thanks 
     chintala

    Hi chintala,
    According to your description, if you want to assign the two different IP to stand for default instance 
    and named  instance, I recommend you set up aliases on a SQL Server with multiple instances. For example, a physical server is named WinServer and 2 instances of SQL Server named WinServer and WinServer\instance1.
    We need to add 1 IP addresse to the WinServer, there is one IP address already assigned to WinServer, 192.168.1.1, by adding one new IP's, 192.168.1.2 .
    We need to move into DNS to configure our host names and aliases.  The physical machine must be steup as a static IP in DNS. SQLAlias1, which point to the default instance on WinServer, will be setup as a DNS with an address of 192.168.1.1.
    SQLAlias2, which will point to WinServer\Instance1, will be setup as a new Host (A) record in DNS with an address of 192.168.1.2.
    When everything has been completed on the DNS side, you need to open up SQL Server Configuration Manager on WinServer and configure the protocols for each instance one at a time, restart the 3 SQL services.
    For more information about how to set up aliases on a SQL Server with multiple instances, you can review the similar article.
    http://kevine323.blogspot.com/2013/08/setting-up-aliases-on-sql-server-with.html
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • SQL Server with BIDS install

    Which version of SQL Server with BIDS is recommended for a starter? I keep on running in various problems when installing and uninstalling.

    SQL Server 2014 is the latest SQL version and from SQL 2012, BIDS is replaced with SSDT(sql server data tools). refer: https://msdn.microsoft.com/library/cc645993.aspx?f=255&MSPPError=-2147217396
    Express edition does not have this. but SQL 2014 'Express with advanced services' edition has it. i do not think  full functionality is available though. 
    if you only want BIDS, you can install SQL 2008R2 express with advanced services edition. google for the link
    this link is for SQL 2008 http://www.microsoft.com/en-us/download/details.aspx?id=1842
    if this is for learning purpose, i would recommend installing sql 2014 enterprise evaluation edition. that way you can get full exposure to SQL product suite
    Hope it Helps!!

  • How to migrate an existing Microsoft SSIS deployment if it is decided to replace SQL Server with an Oracle database?

    Hi Oracle Gurus!
    Currently, I am designing an ETL solution that transforms and loads a lot of data from flat files and sends it to an SQL Server 2008 R2 database for storage. However, at a future point of time, it may be decided to add or even replace SQL Server with an Oracle 11g database.
    Currently, I am writing script transforms in C# to dynamically generate SSIS packages to tansform and load the data into SQL Server. But considering that in future, an Oracle 11g or 12c database might be added to, or replace the SQL Server database, how do I make my script transforms (or whatever else I am developing currently for SQL Server) reusable to the extent possible?
    Or more precisely, what steps do I take, from an Oracle point of view, to ensure that any future migration of data to an Oracle database would be smooth to the extent possible?
    Looking up to my Oracle Gurus for enlightenment in this matter!
    Novice Kid

    When you're writing your on C# code to load data into the SQL Server you have to modify the routines so that they will work with Oracle.
    One approach is to use the extproc agent which would allow you to directly call external programs with all the logic in it to perform the load of your files and to put the data into the Oracle database. Another option would be to use utl_file package (or equivalents) which will allow you to open external files from your Oracle database and to directly read its content and then to pass it to the related tables.

Maybe you are looking for