Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

United Kingdom
115 Posts

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

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?

Flowing Fount of Yak Knowledge

1054 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?


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

Posting Yak Master

United Kingdom
115 Posts

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

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?


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

Flowing Fount of Yak Knowledge

2167 Posts

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

How to ask:

Go to Top of Page
  Previous Topic Topic Next 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.03 seconds. Powered By: Snitz Forums 2000