Thanks Brain.
My final goal is to create database only if database does not exist,
otherwise create it.
When you said "leave out the block", do you want to say remove the
not_if? Could you please help me understanding this?
Thanks,
Ravi
On 12/12/13, Brian Fletcher < "> > wrote:
> Hi Ravi,
>
> From my understanding:
>
> - you pass a block to not_if when you are running ruby code
> - You pass a string to not_if to execute from the shell
>
> See here http://docs.opscode.com/resource_common.html#guards
>
> It looks to me like you want to execute from the shell. So you could try
> leave out the block and see what happens.
>
> execute "Create_DB" do
> command "sqlcmd -S server -i C:\createDB.sql -o C"\Create_db.log"
> not_if "sqlcmd -U user -P secret -S server -b -Q \"select Count (*)
> from master.dbo.sysdatabases WHERE name = 'myDB'\""
> end
>
>
> Thanks,
>
> Brian
>
>
>
> On 12/12/2013 12:26, "Ravindra" < "> > wrote:
>
>>Hello All,
>>
>>I'm writing a recipe where I'm trying to create a database in MSSQL. I've
>>written and execute resource, which is working fine. Now I want it to be
>>executed conditionally, if database exist do not execute the resource.
>>Irrespective of the condition the resource is getting executed every time.
>>
>>The resource I'm using is given below.
>>
>>execute "Create_DB" do
>> command "sqlcmd -S server -i C:\createDB.sql -o C"\Create_db.log"
>> not_if { "sqlcmd -U user -P secret -S server -b -Q \"select Count (*)
>>from
>>master.dbo.sysdatabases WHERE name = 'myDB'\""
>>end
>>
>>
>>Am I doing anything wrong here?
>>
>>Thanks
>>Ravi
>
>
Archive powered by MHonArc 2.6.16.