Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
There is a stored procedure which contains many insert ,update , delete and truncate statements.I want to group all the statements one by one into a table...

For example
SQL
create proc Get_Tables as
begin

UPDATE BB_FMCTransactionsTwo SET wsTradeDate = wsSettleDate WHERE wsEntryCode = 'NRT'
UPDATE BB_FMCTransactionsTwo SET wsOK = 1, wsSpecialLogic = SpecialLogic FROM BB_EntryCode INNER JOIN BB_FmcTransactionsTwo ON EntryCode = wsEntryCode
UPDATE BB_FMCTransactionsTwo SET wsFMCFtNt = '' FROM BB_EntryCode INNER JOIN BB_FmcTransactionsTwo ON EntryCode = wsEntryCode   WHERE wsBS <> 'B' AND ( FMCFtNtB IS NULL OR  FMCFtNtB = 'PR' )
UPDATE BB_B204_Tran SET AMOUNT = dbo.BCA_AMT(Desc1, Desc2, Desc3, Udesc1, Udesc2, Udesc3) WHERE TRANIND = 14 AND  PORTTYPE IN (2,3)
DELETE BB_B204_Tran WHERE TRANIND = 14 AND PORTTYPE IN(2,3) AND (Quantity IS NULL  OR ISNUMERIC(Quantity) = 0 OR Quantity = -1 OR ISNUMERIC(AMOUNT) = 0

end


----Required---
I want to insert the update statements,delete statements into a table one by one...
Create an SP which divides the SP based on type of statemnts(Insert,Update,Truncate) and inserts that into a table row by row..so that the table looks like below



Table

Sl.No Statement
1 UPDATE BB_FMCTransactionsTwo SET wsTradeDate = wsSettleDate WHERE wsEntryCode = 'NRT'
2 DELETE BB_B204_Tran WHERE TRANIND = 14 AND PORTTYPE IN(2,3)
Posted
Updated 12-Jan-14 23:03pm
v7
Comments
Not clear. What exactly you want to do and where is the problem?
Cenarjun 13-Jan-14 3:54am    
There is a stored procedure which contains many insert ,update , delete and truncate statements.I want to group all the statements one by one into a table...Plz help
thatraja 13-Jan-14 4:36am    
Still no idea. Mention clearly with samples in your question. Why do you want that? Update your question with more details
Cenarjun 13-Jan-14 4:42am    
I hv updated..check out
thatraja 13-Jan-14 4:52am    
I saw that but still not clear about purpose. That's why asked for sample(scenario). You got any error? or what? where you're struck?

1 solution

Cannot guess why you want to do that, but I can't see problems: the stored procedure source is just plain textual data: store each line of it in a row of the table.

[update]
If you have to distinguish the different statements (and deal with different stored procedures) then you must parse the stored procedure themselves. This is, generally speaking, a fair complex task, but you may simplify a lot it if you are able to put constraints to the input stored procedures.
[/update]
 
Share this answer
 
v3
Comments
Cenarjun 13-Jan-14 5:00am    
i dont want to store each line into a table row..i want to store one update statement in one row and so on...such that the table should have all the update statements separetly row by row..
Cenarjun 13-Jan-14 5:04am    
See the updated question
Cenarjun 13-Jan-14 5:33am    
ya i know its a complex task..so only posted this question here...Parsing is difficult but i wantd a SP which will determine whether the statements r INSERT,UPDATE OR TRUNCATE
statements then it ll be easy to push them into a table...any help is appreciated

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900