Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have this stored procedure:

SQL
USE master
GO

Alter Procedure RenameInPhysicalDrive
@databaseName VARCHAR(500),
@physicalPath VARCHAR(500),
@logFilePath VARCHAR(500)
AS
BEGIN
DECLARE @MyQuery NVARCHAR(500) =''
SET @MyQuery =( 'CREATE DATABASE  '+' '+ @databaseName+' ON ( NAME= '+@databaseName+
',FILENAME='+ @physicalPath
+',SIZE=10,MAXSIZE=50,FILEGROWTH=5)
LOG ON (NAME=' +@databaseName+'_log'+',FILENAME='+@logFilePath
+',SIZE=5MB,MAXSIZE=25MB,FILEGROWTH=5MB)
GO' )
EXEC sp_executesql @MyQuery
END


It's giving error Incorrect Syntax error near GO .
How can i resolve it?
Posted
Updated 18-Jun-14 16:35pm
v2
Comments
[no name] 18-Jun-14 21:29pm    
GO' )?

1 solution

Try removing the GO. I don't think you need it on a dynamic query.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900