SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 T-SQL does not work when turned into PROC
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Analyzer
Posting Yak Master

United Kingdom
101 Posts

Posted - 06/20/2013 :  12:02:37  Show Profile  Reply with Quote
Hi,

Written some SQL which grabs data into a Temp table then INSERTS into a remote server using Linked Server. Works every time on 10 instances.

As soon as I convert into a STORED PROC it executes without an error but does nothing. EXEC <proc_name>.

Any ideas?

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1050 Posts

Posted - 06/20/2013 :  12:09:25  Show Profile  Reply with Quote
At least I don't. can you show the code? or illustrate the problem somehow with an example?

Cheers
MIK

Edited by - MIK_2008 on 06/20/2013 12:14:03
Go to Top of Page

Analyzer
Posting Yak Master

United Kingdom
101 Posts

Posted - 06/20/2013 :  12:25:26  Show Profile  Reply with Quote
Hi,

Code has no parameters or variables. Just creates a Temp tbl, then grabs data from catalogs into the Temp tbl, then select from temp tbl while INSERT into table on management instance. Always works.

Howe ever when I add CREATE PROC <name> as and then EXEC <name> is does not fail but the proc does nothing as in no values are created. What am I missing about converting into a PROC that would impact its behaviour if executed just as T-SQL?



SET NOCOUNT ON;

IF EXISTS
(SELECT *
FROM tempdb.dbo.sysobjects
WHERE id = OBJECT_ID(N'[tempdb].[dbo].[ReplStats]')
)
DROP TABLE [tempdb].[dbo].[tbl]

CREATE TABLE [tempdb].[dbo].[tbl](
[col1] [nvarchar.....
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2144 Posts

Posted - 06/20/2013 :  12:25:50  Show Profile  Reply with Quote
Privilege error perhaps?








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000