Search code examples
sqlsql-serverjobs

Job with create table


I create a job with the following query

CREATE TABLE P  (ID INT IDENTITY(1,1) ,
                 [employee_name] varchar(10),
                 [employee_salary] varchar(10))
INSERT INTO P ([employee_name] ,[employee_salary] ) 
VALUES ('DANI','1000')

and i execute the job the following way

use[msdb]
EXEC dbo.sp_start_job xxx
GO 
use[DEMO]
select * from P

my question is-why i did not receive a massage "table already exists" while i execute it second time?


Solution

  • dbo.sp_start_job just starts off the job and returns immediately. It doesn't synchronously wait for the result of whatever processing the job is doing.

    You would probably see the expected error message if you check the job history.