0

the definition of a procedure in oracle database very simple. but in SQL Server wife to come to me too. Can you help in this regard. According to the oracle sql server really think excessive unnecessary. Am I wrong, but I do not know this kind of ORACLE process very simple and straightforward. I think oracle systematically.

   for a in  (select * from mytablen but where x = 1) 
        loop  
                 insert into myothertable (a, b, c, d) values (a.AA, a.BB, a.CC,a.DD) 
    end loop;

How can I encode it in sql server. sql server agent management studio express don't work. In SQL Server Management Studio 2014, the New Trigger menu option is disabled trigger button is disabled... job create dont work....

:((

I'm really sorry but
    I'm like a donkey riding up and down from the horse
Community
  • 1
  • 1
pak
  • 230
  • 1
  • 2
  • 11
  • Your question doesn't make a lot of sense. You talk about Oracle but also sql server. And what does your other post have to do with this? What are you trying to do? If you can explain the issue we can help but from what you posted here there is no chance. – Sean Lange Nov 11 '14 at 21:03
  • How do I make the above oracle sql server express. – pak Nov 11 '14 at 21:06
  • though we spend time with you are debugging problems with the above I guess you think the same things you do. Can I debug one I caught in the struggle for hours. I'm not saying it is bad SQL server. I express my current mood. – pak Nov 11 '14 at 21:15
  • @SeanLange I finally found the answer I was looking for. http://forums.asp.net/t/1207630.aspx?Can+you+do+a+FOR+EACH+loop+in+T+Sql+Maybe+in+a+stored+procedure+ – pak Nov 11 '14 at 21:33
  • Good grief...I hope you didn't resort to the looping found at the link you posted. Looping in a database for inserts is about the slowest possible way to accomplish that task. – Sean Lange Nov 12 '14 at 21:15
  • criticized and no help both. – pak Nov 12 '14 at 21:32
  • no I do not. I did as well johns. – pak Nov 12 '14 at 21:34

1 Answers1

1

Your question is confusing but this is what you want...I think.

INSERT  myothertable (a, b, c, d)
SELECT a.AA, a.BB, a.CC, a.DD FROM mytablen WHERE x = 1
JohnS
  • 1,942
  • 1
  • 13
  • 16
  • thanks you for answer.. How do I write a job to run every evening at 01:00 hours. . i dont have sql server agent. SQL Server Agent does not work. I can create a job but did job works and how I can modify them. http://www.mssqltips.com/sqlservertip/2223/how-to-setup-and-manage-sql-server-agent-shared-job-schedules/ – pak Nov 11 '14 at 22:27
  • SQLServerAgent is not currently running so it cannot be notified of this action. – pak Nov 11 '14 at 22:32
  • What version/edition of SQL Server is it? If it is an "express" edition the agent will not be enabled. – JohnS Nov 11 '14 at 23:25
  • ohh! yes i use express.http://stackoverflow.com/questions/26870622/sql-server-management-studio-2014-new-trigger-disable-button. How do I write a job so I will work every evening at 01.00. I wonder if there is a way – pak Nov 11 '14 at 23:40
  • See http://stackoverflow.com/questions/7201061/how-to-create-jobs-in-sql-server-express-edition and http://stackoverflow.com/questions/3788583/automate-a-sql-query-to-run-every-month?lq=1 – JohnS Nov 12 '14 at 00:47
  • INSERT INTO [dbo].[USERINOUT] ([USERID],[DATE]) SELECT USERID,(SELECT @DATES ) FROM [USERINFO] WHERE [DEFAULTDEPTID]>0; is it true? – pak Nov 15 '14 at 08:39
  • It depends on the declaration of @DATES. Is it declared as a DATETIME or DATE type? – JohnS Nov 16 '14 at 21:25