microsoft access help database programing developer
Back to Access Experts About Access Experts Access Experts Websites Access Experts Team Access Experts Services Access Experts Case Studies Access Expert Tips Contact Access Experts OUR BLOG
 
 
Create SQL Server Views using Access code
by Juan Soto
07/23/2009

Use the Create View TSQL command to create views from your code
From time to time I have a need to create views on the fly from my Access code into a SQL Server database. There are two steps involved: Create the view and then grant permissions for it. The first step is relatively simple:

Dim strSQL as String

strSQL = "Create View vw_myView as Select * from tblMyTable"

You would then use an ADODB command object to create the view. Your ADODB credentials will of course need to provide you with the priviledges to create the view. I usually store admin credentials in my code using a password, but you can just as easily prompt the user for thier credentials on the fly.

The second step is more combersome, you will need to assign security priveledges to the new view. I used code available on the net to grant the Select permission to the Public group on the server:

GrantPerm "Public", "vw_myView", "SELECT"

If you need more details please use the contact form on our site.


If you like this tip you will be delighted with our service! Call or write us today for a free quote regarding your computer needs.

Publish this article in your own corporate newsletter or publication! Contact us to obtain a free license.


Home | About Us Why PCExperts | Team | Services | Newsletter | Contact Us
Copyright © 2004