Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Executing 50 views in one shot

Author  Topic 

venkath
Posting Yak Master

202 Posts

Posted - 2006-12-01 : 00:59:18
Hi all

I need to create around 50 views bases on another database as follows

CREATE VIEW address
AS
SELECT *
FROM a2pdb.dbo.address

CREATE VIEW carrier
AS
SELECT *
FROM a2pdb.dbo.carrierk

.
.
.
.

how can i execute all those commands in a one shot..

Thanks

Kristen
Test

22859 Posts

Posted - 2006-12-01 : 03:25:10
[code]
SELECT 'CREATE VIEW ' + TABLE_NAME + '
AS
SELECT *
FROM a2pdb.dbo.' + TABLE_NAME + CHAR(13) + CHAR(10) + 'GO'
FROM INFORMATION_SCHEMA.TABLES
[/code]
Not good for performance to use SELECT * though.

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-01 : 04:24:21
Do you want to get different resultsets or one resultset having all data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -