SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Is there a way to turn off validation?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

phrankbooth
Posting Yak Master

USA
157 Posts

Posted - 12/13/2012 :  23:08:15  Show Profile  Reply with Quote
I have a process that creates SP's which reference objects on other servers which are not yet created. The refernces are in dynamic sql, but the dyn sql is called by non dynamic exec statement in the sp's.

Of course, when the sp is generated sql validates the dynamic ref's which dont exist yet.

Can that behaviour be stopped or worked around so that sp's that are perfectly fine can go through and will work downstream?

--PhB

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/14/2012 :  02:26:16  Show Profile  Reply with Quote
is this inside a SSIS package? if yes, you can set delay validation property to true for delaying validation step until runtime when objects actually get created

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

phrankbooth
Posting Yak Master

USA
157 Posts

Posted - 12/14/2012 :  07:11:50  Show Profile  Reply with Quote
Not in ssis.

--PhB
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/14/2012 :  07:38:38  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Can you post an example of the issue - dynamic sql shouldn't be validated.


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

phrankbooth
Posting Yak Master

USA
157 Posts

Posted - 12/14/2012 :  09:00:05  Show Profile  Reply with Quote
Generally it's like this:

Process 1 adds SP with the following:

create SP
AS
declare @sql = "some sql referencing a DB on another server which is not yet created but will be after the db containing this SP is created"

exec(@sql)

I believe the dynamic does get validated at the exec call.

--PhB
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/14/2012 :  09:48:29  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
>> I believe the dynamic does get validated at the exec call.
Shouldn't.

Are you sure you're creating the SP rather than executing it (maybe by getting the query plan)?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/14/2012 :  09:53:47  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
This works on my machine

create proc ttt
as
declare @s varchar(100)
select @s = 'select * from Me.test.dbo.xxx'
exec (@s)


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000