can a SQL Script refer to and call another sql script?
is there a synatax to run another sql script from within a sql script?
how do you refer to and locate the script you want to run from within another?you could do it by invoking sqlcmd or osql via xp_cmdshell. but why?|||e.g.
C:\tmp>type s1.sql
select 'strt_time'=getdate() into #t1
select count(*) as rows from master..syscolumns where name like '%[a-zA-Z]%'
:r s2.sql
select count(*) as rows from master..sysobjects where name like '%[a-zA-Z]%'
:r s2.sql
drop table #t1
go
C:\tmp>type s2.sql
select 'elapsed(ms)'=datediff(ms,strt_time,getdate()) from #t1
go
C:\tmp>osql -n -Usa -Spdsrv -i s1.sql
Password:
(1 row affected)
rows
----
5080
(1 row affected)
elapsed(ms)
----
46
(1 row affected)
rows
----
1400
(1 row affected)
elapsed(ms)
----
76
(1 row affected)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment