PDA

View Full Version : Set temp macro from result of Run SQL action


raghuk
10-29-2012, 02:39 PM
Hello,

I have a need to set a local variable macro based on if the database exists or not.

I have the following query in "Run SQL" action.

if db_id('%CurrentDatabaseName%') is null
BEGIN
-- ???? STEP TO set local variable which effectively says 'NO DB'
END

How can I achieve this?

Thanks!

raghuk
10-29-2012, 02:44 PM
Hello,

I have a need to set a local variable macro based on if the database exists or not.

I have the following query in "Run SQL" action.

if db_id('%CurrentDatabaseName%') is null
BEGIN
-- ???? STEP TO set local variable which effectively says 'NO DB'
END

How can I achieve this?

Thanks!

In fact, if there is an "expression" that I could use to call this I would love that so that I can use the expression in "Build only if macro or expression" is true!

Thank you!

kinook
10-29-2012, 06:32 PM
http://msdn.microsoft.com/en-us/library/ms189484.aspx

raghuk
10-30-2012, 10:49 AM
http://msdn.microsoft.com/en-us/library/ms189484.aspx

Thanks :), I am aware of the T-SQL syntax and I'm sure this is not the forum to discuss T-SQL issues.

The real question being, how do I set the value from T-SQL variable back to a macro defined within Visual Build Pro?

Thanks again!

kinook
10-30-2012, 10:56 AM
Print the variable's value, parse it out of the LASTSTEP_OUTPUT macro value, and store in a macro.
http://msdn.microsoft.com/en-us/library/ms176047%28SQL.90%29.aspx
http://www.kinook.com/VisBuildPro/Manual/scriptevents.htm

raghuk
10-31-2012, 11:29 AM
Thank you! You are amazing as always!

raghuk
08-20-2013, 05:54 PM
name
--------------------------------------------------------------------------------------------------------------------------------
Music_log




Hello,

When I run the SQL to assign it to a variable, above is the output that I get from SQL. How do I parse to get only "Music_log"?

Thank you!

kinook
08-20-2013, 09:06 PM
See the attached sample.

Shiamak
09-04-2013, 06:22 PM
Do you have this .bld sample for v7.7 pro?

kinook
09-04-2013, 07:07 PM
No, but it might work if you change the version in the .bld file (in a text editor) from 8 to 7.