0

I am using Microsoft SQL server. the following code works if run from a QUERY:

SELECT * 
INTO mydatabase.dbo.atable 
FROM linkedserver.sandbox.dbo.atable

but it does not if inserted into a stored procedure:

SET ANSI_NULLS ON  GO 
SET QUOTED_IDENTIFIER ON  GO

ALTER PROCEDURE dataMigration   
AS  BEGIN   
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.     

 SET NOCOUNT ON;

 -- Insert statements for procedure here     
SELECT *     
INTO mydatabase.dbo.atable  
FROM linkedserver.sandbox.dbo.atable   

 END   
GO

Command(s) completes successfully but no table is created into mydatabase. Sorry for the trivial question. I had a look at similar issues but i did not find a case similar to mine.

Thank you for your help.

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
user1536396
  • 489
  • 2
  • 7
  • 22

2 Answers2

3

You have to execute the stored Procedure after you run the code to alter it.

try running:

exec dataMigration
1

Right clickOption Image the store procedure and click "Execute Store procedure"

Mytroy2050
  • 179
  • 1
  • 2
  • 17