You are here: Create view from cursor « MsSQL Server « IT news, forums, messages
Create view from cursor

Posted by db55 on 10/02/31 11:47

I have multiple locations that I want to create views for each
individual location.

I am using a cursor to create the views for each location. So, the
cursor grabs site #1 then <should> create view_site_#1, then grab site
#2 and <should> create view_site_#2.

For some reason it doesn't like the view name with the @site in it.
Any ideas of how to get this done?

Here's the cursor...

declare @site varchar(5)

declare c_site cursor for
select station from VHAISLCAUDIA.VISN_SITE
order by station


open c_site
fetch from c_site
into @site

while (@@fetch_status = 0)
begin

CREATE VIEW Site_All_Data_+ @site
AS
SELECT *
FROM dbo.[600_All_Suggested_Data]
WHERE (Site = @site)


Print 'View for ' + @site + ' Created'

fetch next from c_site into @site
end
close c_site
deallocate c_site
return

end

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация