DTS Run TSQL Statements

  • Dear Friends,

    I have sql statments which stored in a table.

    The sql statement contains Delete and Insert statement.

    I want to select this strings and run, so that the concern tables will be updated.

    The sql statements which stored in a table are below:

    DELETE FROM [trnswinward] WHERE [BranchId] = 1 AND [GCNo] = 14261 AND CONVERT(VARCHAR(20), [BDate], 120) = N'2005-07-08 00:00:00'

    INSERT INTO [trnswinward] ([BranchId], [MemoNo], [ArrivMemo], [ArrivTruck], [DespDate], [ArrivDate], [MFrom], [MTo], [OCtBillNo], [OCTDate], [OCTType], [UserID], [GCNo], [BDate], [FrmBranch], [ToBRanch], [CNRID], [CNRName], [CNEID], [CNENAme], [OCTFType], [OCTRcptNo], [OctAmount], [DespArticle], [RecdArticle], [DmgdArticle], [Packing], [CommodityID], [Item], [BillType], [Freight], [Local], [FOV], [Hamali], [Bilty], [AOC], [DDCharge], [Others], [Discount], [TFreight], [Weight], [CWeight], [Remarks], [ISFTL], [ISDoorDelivery], [IsMemo], [ISBDownloaded], [IsDADownloaded], [IsSADownloaded], [ISDRDownloaded], [ISSRDownloaded], [ISHODownloaded], [UploadDate], [IsLocal], [IsCoLoader], [DelyType], [BkgType], [TripNo], [VehArrivNo], [updton], [SrcEntry], [UnloadPlace], [Value], [serverdate], [MemoCRDate], [SplClient], [EntrySrc], [TotFrt], [TaxAbate], [ChgFrt], [SVCTax], [TaxPayBy], [VerInfo])

    VALUES (1, 2933517, 3251047, N'GJ3U9307', N'20050715 00:00:00', N'20050715 00:00:00', 6, 1, N'3997940', N'20050715 00:00:00', N'          ', N'RASIK', 14261, N'20050708 00:00:00', 16, 1, 0, N'V.NAT & CO.', 22122, N'VIJAY HEAT ELECTRICALS', N'E         ', N'3997943', 1195.0000, 2, 2, 0, 1, 2, N'ELE.GOODS', N'T', 50.0000, 0, 17.0000, 8.0000, 25.0000, 10.0000, 0, 0, 0, 110, 28, 50, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, N'07/18/2005 09:26:45 AM', 0, N'N', N'G', N'S', 3263615, 2901117, N'20050716 17:08:00', N'F', N'SARAN', 34030.0000, N'20050718 09:25:41', N'20050716 00:00:00', N'N', N'B', 110.0000, 0, 110.0000, 0, N' ', N'AA')

    I want to carry out this task through DTS-Job schedule.

    Thanks.

    R.M. Joseph

     

     

     

  • If I'm understanding you correctly...

    1.) Create a connection to your sql server

    2.)Create a SQL Task

    3.) Past your t-sql code from above in the SQL Task.

    Should be easy.

    Schedule the DTS package in your Jobs Interface.

    -- M Kulangara


    Mathew J Kulangara
    sqladventures.blogspot.com

  • Dear Mr. Mathew,

    Your idea is good.  I want to how to insert the long sql statement in column of varchar (2000).

    I could not insert more than 256 char.  Why?

    Then, I could use the SQL Task.

    If you know that please guide me.

    Thanks.

    R. M. Joseph

     

     

  • You want to insert the SQL statements as a string into a varchar(2000) column of a table?  Try replacing all the single quotes with double quoutes then wrap the entire string with single quotes.

    Insert into mytable

    values ('DELETE FROM [trnswinward] WHERE [BranchId] = 1 AND [GCNo] = 14261 AND CONVERT(VARCHAR(20), [BDate], 120) = N"2005-07-08 00:00:00"

    INSERT INTO ....

    ')

    Greg

     

    Greg

  • Thank you Mr. Greg,

    As you advised, I have replaced the single quote with double quote and inserted the sql statement in the column.

    Again I update the column by replacing the double with single quote.  Then EXEC the sql statement.  The job is over but it is long cut.

    Thank you Mr. Greg and Mr. Mathew for your support and contribution.

    R. M. Joseph

     

     

     

     

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply