Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hello everyone.There's a task that I'm tring to accomplish that's been driving me nuts all day. I finally have an idea that I want to get in code. The problme is that I don't know if the idea I have is supported in SQL syntax. If the end result of the code was a view then that would be great, but I think this idea I have has to be a stored procedure. If you guys could take a look at the following psuedo code and tell me if this is T-sql supported and give me the key words I need to work with or tutorial or links or even a little code snippet help that would be super great. I'll appreciate any help I can get. for i 1 to Length_Of_OEINVH_table/num of records varOrdNumbr = OEINVH_table.ORDERNUMBER varInvNumber = OEINVH_table.INVNUMBER insert into TempTbl (a,b,c,d) select a, b, c from OE_Sales_History_Details where OrderNumber = varOrdNumbr, varInvNumbernext i
James K
Master Smack Fu Yak Hacker
3873 Posts
Posted - 2013-08-09 : 14:26:07
I think this is what it translates to:
INSERT INTO TempTbl (a,b,c,d)SELECT a,b,c,INVNUMBERFROM OE_Sales_History_Details oh INNER JOIN OEINVH_table ot ON ot.ORDERNUMBER=oh.OrderNumber
Try it in a safe, disposable development environment to see if it does what you want it to do before you do any irreparable harm to your production data.
viperbyte
Posting Yak Master
132 Posts
Posted - 2013-08-09 : 15:40:05
That looks good to me. I'll have to create that temp table now and give that code a whirl. If I'm not done with the temp table in the next hour or so I'll have to finish that and the test during the weekend. Super thank you very much James.