Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Join on field names

Posted on 2013-01-10
17
Medium Priority
?
366 Views
Last Modified: 2013-01-11
I need to join two SQL tables together.
"Table 1" contains the Question text for "Table 2"
"Table 2" contains my survey results.
My goal is to join the two tables together on their field names.

Example output:
Org_ID     Organization_Name    Consentor_a5
1               North Hospital           contact@north.com

Table 1:
SELECT  [ORGANIZATION_NAME]
      ,[CONSENTOR_A5]
      ,[CONTACT_NAME]
      ,[TITLE]
      ,[EMAIL_ADDRESS]
      ,[PHONE_NUMBER]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
  FROM headers_core_priveleges

Open in new window



Table 2:
SELECT  [ORG_ID]
      ,[ORGANIZATION_NAME]
      ,[CONSENTOR_A5]
      ,[CONTACT_NAME]
      ,[TITLE]
      ,[EMAIL_ADDRESS]
      ,[PHONE_NUMBER]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
  FROM core_priveleges

Open in new window

0
Comment
Question by:swaggrK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 2
17 Comments
 

Author Comment

by:swaggrK
ID: 38763863
This is what I meant to type for what I am trying to accomplish:

Example
Organization_Name            Consentor_A5
Organization Name             Email Address
North Hospital                    contact@north.com
0
 
LVL 22

Expert Comment

by:mcsween
ID: 38763876
You will need an inner join.  What field in each table has the same value to be joined on?  With the assumption of Org_ID being the foreign key the following code should do what you need.

SELECT table1.Org_ID, table2.Organization_Name, table2.Consentor_a5
FROM table1
INNER JOIN table2
ON table1.Org_ID=table2.Org_ID

Open in new window

0
 

Author Comment

by:swaggrK
ID: 38763909
Org_ID is only in "core_priveleges"
it is not in headers_core_priveleges

I need to join the tables on there field names. Both tables contain the same
field names. The only field that is not in both is org_id
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 22

Expert Comment

by:mcsween
ID: 38764004
You cannot join on field names; you can only join on field values.  How are you linking the question to the answer then?  You should have a key field that is the same on all matching records in both tables.
0
 
LVL 41

Expert Comment

by:ralmada
ID: 38764253
Your question is not clear, but I am guessing you're looking for something like this:

declare @strSQL varchar(max)

set @strSQL = 'select ORG_ID, '

select @strSQL = @strSQL + '[ORGANIZATION_NAME] as [' + [ORGANIZATION_NAME] + '],',
		 ' [CONSENTOR_A5] as  [' + [CONSENTOR_A5] + '],',
--		 ... and so on ...
      		 ' [CORE_PRIVILEGES_A19_M2] as [' + [CORE_PRIVILEGES_A19_M2] + ']'
  FROM header_core_priveleges 

set @strSQL = @strSQL + ' from core_privileges'

exec(@strSQL)

Open in new window


If not please post sample data (from both tables) and expected result (what you want from the query)
0
 

Author Comment

by:swaggrK
ID: 38764297
@ ralmada I get the following error when I attempt to run

Error:
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
0
 

Author Comment

by:swaggrK
ID: 38764332
I have now created the following table that contains the questions(q_text), the matching field name(q_field) from the table "core_privelieves"

I am merely trying to join the question text from "q_core_priveleges" to the table that contains the survey results core_priveleges.




New Table 1:

SELECT q_id, q_field, q_text
FROM q_core_priveleges

q_id	      q_field	                                q_text
1	     ORGANIZATION_NAME	        Organization Name
2	     CONSENTOR_A5	                        Email Address
3	      TITLE	                                        Title

Open in new window



Table 2 :

SELECT  [ORG_ID]
      ,[ORGANIZATION_NAME]
      ,[CONSENTOR_A5]
      ,[CONTACT_NAME]
      ,[TITLE]
      ,[EMAIL_ADDRESS]
      ,[PHONE_NUMBER]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
  FROM core_priveleges
                                  

Open in new window

0
 
LVL 41

Expert Comment

by:ralmada
ID: 38764439
sorry the select should have been like this

select @strSQL = @strSQL + ' [ORGANIZATION_NAME] as [' + [ORGANIZATION_NAME] + '], ' +
		 ' [CONSENTOR_A5] as  [' + [CONSENTOR_A5] + '], ' +
--		 --... and so on ...
      		 ' [CORE_PRIVILEGES_A19_M2] as [' + [CORE_PRIVILEGES_A19_M2] + ']'
  FROM header_core_priveleges 

Open in new window

0
 
LVL 41

Expert Comment

by:ralmada
ID: 38764488
I have now created the following table that contains the questions(q_text), the matching field name(q_field) from the table "core_privelieves"
Still not clear, so I will keep guessing

select a.*, b.*
from core_privileges a
inner join (
	SELECT 	q_id, 
		q_field, 
		q_text, 
		(select max(q_text) from q_core_privileges where q_field = 'ORGANIZATION_NAME') as [ORGANIZATION_NAME],
		(select max(q_text) from q_core_privileges where q_field = 'CONSENTOR_A5') as [CONSENTOR_A5],
		(select max(q_text) from q_core_privileges where q_field = 'TITLE') as [TITLE]
	FROM q_core_priveleges
	) b on a.ORGANIZATION_NAME = b.ORGANIZATION_NAME and a.[CONSENTOR_A5] = b.[CONSENTOR_A5] and a.TITLE = b.TITLE

Open in new window


If not, can you post a meaningful example with sample data from both tables and the expected result (not just the explanation but a resultset with what you expect to obtain)?
0
 

Author Comment

by:swaggrK
ID: 38764992
@ ralmada, your example returned no results.

Below are both tables with values.
Table 1 contains the quesstion ID, question field name and question text.
Table 2 Contains the answers from 3 different organizations.
I need to create a report that shows the question text(qtext) along wiht the answers from Table 2.

So, I would like for the Question Text to output after the field name and before the results.


Table 1:

SELECT TOP qid, qfield, qtext
FROM q_core_privileges

qid	 qfield	                                                  qtext
1	ORGANIZATION_NAME	                          What is Your Organization Name
2	GROUP	                                                  What is Your Group
3	DO_YOU_HAVE_CORE_PRIVILEGES	          Do You Have Core Privileges

Open in new window




Table 2:

SELECT  ORG_ID, ORGANIZATION_NAME, [GROUP], DO_YOU_HAVE_CORE_PRIVILEGES 
FROM core_privileges1

ORG_ID	ORGANIZATION_NAME	        GROUP	DO_YOU_HAVE_CORE_PRIVILEGES	
1	Northwestern Hospital	                UHC	        Yes	
2	Rush Medical Center	                UHC	        Yes	
3	University of Chicago	                UHC    	Yes	

Open in new window

0
 
LVL 41

Expert Comment

by:ralmada
ID: 38765381
OK, so now we have samples data from the two tables, but you're still missing the resultset

>>So, I would like for the Question Text to output after the field name and before the results.<<

Do you mean like this?


ORG_ID	ORGANIZATION_NAME	        GROUP DO_YOU_HAVE_CORE_PRIVILEGES	
What is Your Organization Name    What is Your Group  Do You Have Core Privileges

1	Northwestern Hospital	                UHC	        Yes	
2	Rush Medical Center	                UHC	        Yes	
3	University of Chicago	                UHC    	Yes	

Open in new window



in that case try:

select 	'' as ORG_ID,	
	(select max(q_text) from q_core_privileges where q_field = 'ORGANIZATION_NAME') as [ORGANIZATION_NAME],
	(select max(q_text) from q_core_privileges where q_field = 'CONSENTOR_A5') as [CONSENTOR_A5],
	(select max(q_text) from q_core_privileges where q_field = 'TITLE') as [TITLE]
	... and so on ...
union all
select * from core_privileges

Open in new window

0
 
LVL 41

Expert Comment

by:ralmada
ID: 38767445
or using PIVOT

select 
	*
from (
	SELECT '' as ORG_ID, qfield, qtext
	FROM q_core_privileges
) o
pivot(max(qtext) for qfield in ([ORGANIZATION_NAME]
      ,[CONSENTOR_A5]
      ,[CONTACT_NAME]
      ,[TITLE]
      ,[EMAIL_ADDRESS]
      ,[PHONE_NUMBER]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
)) p
union all
select * from core_privileges

Open in new window

0
 

Author Comment

by:swaggrK
ID: 38767513
Thanks ralmada but I keep getting the following error with both queries...

All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
0
 
LVL 41

Expert Comment

by:ralmada
ID: 38767531
that's because you need to have the same # columns in both sides of the UNION. You've mentioned that both tables were the same except for the ORG_ID column, which I've manually added in the first part of the UNION ALL.

Run each query on both side of the UNION separately, and make sure you have the same # of columns. Once the columns match, you can combine them in the UNION ALL
0
 

Author Comment

by:swaggrK
ID: 38767696
Thanks ralmada, the following worked, but I had to create a table that did not contain org_ID.
But, this will not be the case, I will need the org_ID.
How can I use my core_privileges table that does contain org_ID?


select 
	[ORGANIZATION_NAME]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
from (
	SELECT '' as ORG_ID, qfield, qtext
	FROM q_core_privileges
) o
pivot(max(qtext) for qfield in ([ORGANIZATION_NAME]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
)) p
union all
select * from core_privileges2

Open in new window

0
 
LVL 41

Accepted Solution

by:
ralmada earned 800 total points
ID: 38767783
>>I had to create a table that did not contain org_ID.<<

why? I don't understand why you left the org_ID out.

I have added a phoney org_id in the q_core_privileges:

SELECT '' as ORG_ID, qfield, qtext
      FROM q_core_privileges

So assuming both tables have the same columns except for ORG_ID, then the below should work:

select 
	ORG_ID
      ,[ORGANIZATION_NAME]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
from (
	SELECT '' as ORG_ID, qfield, qtext
	FROM q_core_privileges
) o
pivot(max(qtext) for qfield in ([ORGANIZATION_NAME]
      ,[GROUP]
      ,[DO_YOU_HAVE_CORE_PRIVILEGES]
      ,[CORE_PRIVILEGES_A16_M1]
      ,[CORE_PRIVILEGES_A16_M2]
      ,[CORE_PRIVILEGES_A17_M1]
      ,[CORE_PRIVILEGES_A17_M2]
      ,[CORE_PRIVILEGES_A18_M1]
      ,[CORE_PRIVILEGES_A18_M2]
      ,[CORE_PRIVILEGES_A4_M1]
      ,[CORE_PRIVILEGES_A4_M2]
      ,[CORE_PRIVILEGES_A5_M1]
      ,[CORE_PRIVILEGES_A5_M2]
      ,[CORE_PRIVILEGES_A6_M1]
      ,[CORE_PRIVILEGES_A6_M2]
      ,[CORE_PRIVILEGES_A7_M1]
      ,[CORE_PRIVILEGES_A7_M2]
      ,[CORE_PRIVILEGES_A9_M1]
      ,[CORE_PRIVILEGES_A9_M2]
      ,[CORE_PRIVILEGES_A10_M1]
      ,[CORE_PRIVILEGES_A10_M2]
      ,[CORE_PRIVILEGES_A8_M1]
      ,[CORE_PRIVILEGES_A8_M2]
      ,[CORE_PRIVILEGES_A11_M1]
      ,[CORE_PRIVILEGES_A11_M2]
      ,[CORE_PRIVILEGES_A13_M1]
      ,[CORE_PRIVILEGES_A13_M2]
      ,[CORE_PRIVILEGES_A14_M1]
      ,[CORE_PRIVILEGES_A14_M2]
      ,[CORE_PRIVILEGES_A2_M1]
      ,[CORE_PRIVILEGES_A2_M2]
      ,[CORE_PRIVILEGES_A19_M1]
      ,[CORE_PRIVILEGES_A19_M2]
)) p
union all
select * from core_privileges

Open in new window

0
 

Author Comment

by:swaggrK
ID: 38768522
Thanks ralmada! This works just fine.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question