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
 General SQL Server Forums
 New to SQL Server Programming
 T-SQL does not work when turned into PROC

Author  Topic 

Analyzer
Posting Yak Master

115 Posts

Posted - 2013-06-20 : 12:02:37
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
Master Smack Fu Yak Hacker

1054 Posts

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

Cheers
MIK
Go to Top of Page

Analyzer
Posting Yak Master

115 Posts

Posted - 2013-06-20 : 12:25:26
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
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2013-06-20 : 12:25:50
Privilege error perhaps?








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

Go to Top of Page
   

- Advertisement -