[This topic is migrated from our old forums. The original author name has been removed]
Hi,
I'm involved with a conversion from sybase to sql server and I am trying to script out the stored procedures to individual files.
The problem that i'm having is trying to get the '@export' command to have a variable filename.
Here is the sql script:
@export on;
-- cursor for stored procedure objects
DECLARE a_cursor CURSOR
FOR
SELECT name FROM sysobjects where sysobjects.type = 'p' and name = 'pr_a100_sor_claims_by_age'
FOR read only
go
OPEN a_cursor
go
-- Get first cursor row
declare @proc varchar(30)
FETCH a_cursor
INTO @proc
-- process cursor rows
WHILE @@SQLSTATUS = 0
BEGIN
-- export the ddl for the procedure
* @export set filename="C:\citgwp\Junk\" + @proc + ".sql" format="sql";*
* @ddl procedure=@proc drop="true";*
-- Get next cursor row
FETCH a_cursor
INTO @proc
END
go
-- cleanup cursor
CLOSE a_cursor
DEALLOCATE cursor a_cursor
go
@export off;
The follwowing errors occur:
*09:51:11 [-- - 0 row(s), 0.000 secs] The Filename is not set for the @export command*
Thanks,
Gary
Re: Help with using variable with @export commands
Hi Gary,
Sorry, you cannot use DbVisualizer client side commands like @export and @ddl within an SQL block like you try to do. To export all stored procedures to individual files, use the Export Schema feature and include ${dbvis-object}$ somewhere in the filename, e.g. "${dbvis-object}$.sql". ${dbvis-object}$ is then replaced with the name of each procedure during export.
Best Regards,
Hans
a
anonymous
said
over 11 years ago
[This reply is migrated from our old forums. The original author name has been removed]
Re: Help with using variable with @export commands
Hi Hans,
Your suggestion is exactly what I want to do.
Unfortunately I can't seem to get it to work. It creates one file called ${dbvis-object}$.sql with all the stored procs inside.
I'm sure that i'm not understanding something.
Here is the export dialog.
[image removed]
Thanks,
Gary
Edited by: Hans Bergsten on Mar 26, 2013 9:48 PM
Hans Bergsten
said
over 11 years ago
[This reply is migrated from our old forums.]
Re: Help with using variable with @export commands
Hi Gary,
Sorry I had to remove your screenshot; it pushed the Reply button so far to the right that I couldn't reply.
Your input looks fine. The problem is most likely that you have set the DbVisualizer variable delimiters to something other than ${ and }$ in Tool Properties. Either replace ${ and }$ with your delimiters when you use the dbvis-object variable or change the delimiters back to the default in Tool Properties.
Best Regards,
Hans
a
anonymous
said
over 11 years ago
[This reply is migrated from our old forums. The original author name has been removed]
Re: Help with using variable with @export commands
Hi Hans,
That was the problem. I had '$$' and '$$' as the variable delimiters. They seemed to be the default since I'm sure i've never changed them before. However, I changed them to '${' and '}$' to match your documentation help file examples.
It worked great. Problem solved.
Thanks very much,
Gary
anonymous