[dba-SQLServer] Union query

Mackin, Christopher CMackin at quiznos.com
Thu Sep 30 15:05:15 CDT 2004


Query Analyzer if possible, alternatively you can set it as the CommandText of an ADO command object in VB(A) and have it execute that way or you can use the View or Query (depending on version of Access) window in an ADP.

You will also want to add something like:
GRANT SELECT ON dbo.MyView TO Public

so the security is set (the above makes it readable to EVERYONE, so make sure to adjust accordingly.

This statement can go beneath the Creation code as follows:


Create View dbo.MyView
AS
Select * From     dbo.schoolEnrollmentNumberselemonly
Union all
Select * From     dbo.SchoolEnrollmentNumberselemcombo
GO

GRANT SELECT ON dbo.MyView TO Public
GO

or it can be run independently after the object is created.

-Chris Mackin

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Klos,
Susan
Sent: Thursday, September 30, 2004 1:55 PM
To: 'dba-sqlserver at databaseadvisors.com'
Subject: RE: [dba-SQLServer] Union query


OK.  Where do I write this code?

Susan Klos
Senior Database Analyst
Evaluation and Reporting
Florida Department of Education
850-245-0708 
sc 205-0708
 

-----Original Message-----
From: Mackin, Christopher [mailto:CMackin at quiznos.com] 
Sent: Thursday, September 30, 2004 3:49 PM
To: dba-sqlserver at databaseadvisors.com
Subject: RE: [dba-SQLServer] Union query

Certainly,

Just use:

Create View dbo.MyView
AS
Select * From     dbo.schoolEnrollmentNumberselemonly
Union all
Select * From     dbo.SchoolEnrollmentNumberselemcombo


Then you can call dbo.MyView from whereever

-Chris Mackin

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Klos,
Susan
Sent: Thursday, September 30, 2004 1:34 PM
To: 'dba-sqlserver at databaseadvisors.com'
Subject: [dba-SQLServer] Union query


Please be kind.  I am doing this from an Access viewpoint and am having
trouble making a transition.

I have created a union query:

Select *

>From     dbo.schoolEnrollmentNumberselemonly  (this is a view)

Union all

Select *

>From     dbo.SchoolEnrollmentNumberselemcombo (this is a view)

 

Now I need to be able to call this query in another view.  Is this possible?
How?

 

Susan Klos

Senior Database Analyst

Evaluation and Reporting

Florida Department of Education

850-245-0708 

sc 205-0708

 

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list