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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Need help with a JOB step...

Author  Topic 

NCXX
Starting Member

3 Posts

Posted - 2003-01-31 : 16:31:34
Hello,

I am trying to create a job in which one of the steps is supposed to take rows of data from one table and put them in another. The step type is TSQL and my logic is as follows:
INSERT INTO CULLET
SELECT *
FROM GRCULLET
WHERE "TOTALLOSS" <> 0
ORDER BY "Reason #"
My problem is that the JOB fails everytime when attempting to execute this step. However the exact same logic executes properly in my Query Analyzer. And I found out that if I comment out the "WHERE" and the "ORDER" lines of code, the JOB will execute successfully. Basically, the JOB will insert the entire table but not certain rows. What am I doing wrong? Is it simply syntax? Thanks in advance for the help.

Bryan

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-01-31 : 16:40:19
Well, you really don't need the ORDER BY. And no, you can't rely on SQL Server to INSERT the rows in the same order unless you have a clustered index on that column (Reason #) This still won't guarantee when you SELECT that they'll come out in the same order either.

Also try removing the double quotes (") from the WHERE clause and see if that fixes it (it should work without the quotes as you don't have any spaces in the TotalLoss column name)

Go to Top of Page

NCXX
Starting Member

3 Posts

Posted - 2003-01-31 : 23:16:13
Hey robvolk,

Thanks! I took out the quotes from the WHERE and it worked. I left the ORDER and that worked also. My rows are inserted to the new table in the order I asked for. Thanks again for your help.

Go to Top of Page
   

- Advertisement -