What is your SQL Server version? Is there more to the procedure? I just tried it in SQL 2019 and it worked just fine, the date was returned.
Can't run query if defining temp table
OHPRS Admin
211
Reputation points
I have the following T-SQL:
alter procedure myProc_sp
AS
BEGIN
create table #myTable (
retireeId varchar(12)
)
select getDate()
return
END
With the 'create table' statement in there, it returns zero rows. If I comment out the 'create table' it returns the current date/time. I've also tried 'declare @myTable table()'. I've been creating stored procedures with 'create table' and 'declare table()' for years w/o problem. I've tried running some of those other procedures just now an they run just file, so I don't think this is a privilege issues on the part of the user. Just in case, I've gone ahead and [re]granted create table priv to the public user.
What am I doing wrong?