2009/5/19 Daniel <[email protected]>:
> Hello,
> I have a stored procedure for SQL Server and I would like to be able
> to execute the code to create the stored procedure using SA. Here's
> the basic idea.
> The problem is that I'm getting an error complaining about invalid
> syntax "ProgrammingError: (ProgrammingError) ('42000', "[42000]
> [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near
> the keyword 'CREATE'"
> I know the stored procedure call works since I can run it against the
> database. What do I need to do to execute my script from SA?
Execute each command separately. I've never seen a DBAPI driver that
allows execution of more than one full command in the same query.
myStoredProcedure = ["""
IF object_id('mySP') IS NOT NULL
BEGIN
DROP PROCEDURE mySP
END""",
"""
CREATE PROCEDURE mySP
AS
DECLARE @aVar VARCHAR(48)
BEGIN
SELECT TOP 1
@aVar = aVar
FROM [dbo].[someTable] (UPDLOCK)
WHERE
priority > 0
ORDER BY
priority DESC
SELECT
@aVar AS aVar
END
"""]
for command in myStoredProcedure: engine.execute(command)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---