Set Quoted_Identifier On
Go
Set Ansi_Nulls On
Go
Alter Procedure spReport_SomeFooReport
@.SearchFromThisDate datetime = null, @.SearchToThisDate datetime = null
As
Declare @.TableUniqueIdentifier varchar(80), @.SQLString varchar(5000)
set @.TableUniqueIdentifier = newid()
set @.TableUniqueIdentifier = 'Report_SomeFooReport' + @.TableUniqueIdentifier
set @.TableUniqueIdentifier = replace(@.TableUniqueIdentifier, '-', '7')
set @.SQLString = 'Create Table ' + @.TableUniqueIdentifier + ' (xxx varchar(40))'
exec @.SQLString
Return
Go
Set Quoted_Identifier Off
Go
Set Ansi_Nulls On
Go
--------------
the error is:
Server: Msg 2812, Level 16, State 62, Line 12
Could not find stored procedure 'Create Table Report_SomeFooReport06EEEC8D7EA6A74D0178EDD79E999B (xxx varchar(40))'.
So may'be a format issue or something,
im trying to create "temp" tables for sql 2005 report services in my Stored procedures which would have a sql job to get deleted at 23:00This looks like Sql Server. If that's the case, try using
EXEC (@.SQLString)|||RedNeckGeek is right, the EXEC without the parentheses means you're calling a stored procedure.|||also, it's bad form to create permanent tables on the fly from sprocs.
If your database schema is well designed, there would be no need for this. Perhaps use a temp table instead?
Or use a single permanent table for all your reports since they all have exactly the same structure, with just a single column, xxx varchar(40). You could add another column to identify the report instance.|||I would like to know howyou plan to reference that table in the future|||I would like to know howyou plan to reference that table in the future
the only possible way I know of would be to return the table name as an out param from the sproc.
Sunday, March 25, 2012
Creating a unique temp table.
Labels:
ansi_nulls,
creating,
database,
datetime,
microsoft,
mysql,
null,
ongoalter,
ongoset,
oracle,
procedure,
quoted_identifier,
searchfromthisdate,
searchtothisdate,
server,
spreport_somefooreport,
sql,
table,
temp,
unique
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment