March 1, 2012 at 3:33 am
hi all,
i need a Dynamic script for creating (view, Stored procedure,function) in selected db.
for example
like if i have a 10 db whose name start with XX_
where i can apply a
create view statement on that db's where the db name start with XX_
Any Suggestion or Help is Appreciated !!!
March 1, 2012 at 7:35 am
use this to fetch DB Names
Select name from sys.databases
where name like 'xx%'
and run your view or procedures using "use DBNAME and query".
can we know what are you trying to do it?
Regards
Durai Nagarajan
March 1, 2012 at 8:40 am
durai nagarajan (3/1/2012)
use this to fetch DB NamesSelect name from sys.databases
where name like 'xx%'
and run your view or procedures using "use DBNAME and query".
can we know what are you trying to do it?
how abt this
DECLARE @grantExecute varchar(8000)
select @grantExecute = 'IF ''?'' NOT IN(''master'', ''model'', ''msdb'', ''tempdb'') and ''?'' like ''CC_%'' BEGIN USE [?]
here the sql query which i want to execute with a (')
March 5, 2012 at 1:24 pm
You mean execute this query by means of sp_msforeachdb ?
March 5, 2012 at 11:48 pm
ffoerster (3/5/2012)
You mean execute this query by means of sp_msforeachdb ?
yes by sp_msforeachdb
do u have any better script or any script please put on the forum.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply