Click here to Skip to main content
15,892,005 members
Home / Discussions / Database
   

Database

 
GeneralRe: Help with SQL Query Please Pin
Grimolfr13-Jul-04 8:46
Grimolfr13-Jul-04 8:46 
GeneralRe: Help with SQL Query Please Pin
Steven Campbell13-Jul-04 8:54
Steven Campbell13-Jul-04 8:54 
GeneralODBC_CONFIG_SYS_DSN problem! pls help!!!!!!!!!!!!! Pin
girl_lash12-Jul-04 20:23
girl_lash12-Jul-04 20:23 
GeneralRe: ODBC_CONFIG_SYS_DSN problem! pls help!!!!!!!!!!!!! Pin
Grimolfr13-Jul-04 8:39
Grimolfr13-Jul-04 8:39 
GeneralODBC_CONFIG_SYS_DSN problem! pls help!!!!!!!!!!!!! Pin
girl_lash12-Jul-04 20:22
girl_lash12-Jul-04 20:22 
GeneralManaging BLOBs Pin
La hadita tripiadora12-Jul-04 14:15
La hadita tripiadora12-Jul-04 14:15 
GeneralCombo Box Problem Pin
Steve4512-Jul-04 13:59
Steve4512-Jul-04 13:59 
GeneralSQL permissions (uugghh!!) Pin
Colin Angus Mackay12-Jul-04 5:36
Colin Angus Mackay12-Jul-04 5:36 
I have a database under development. For testing I created a couple of tables with the user account 'test_schema' which is their owner.

If I use the SQL below to query the structure of the table as 'sa' then some of the fields come back as null whereas if I perform the same query as 'test_schema' I get all the fields correctly.

DECLARE @table_name varchar(128);
SET @table_name = 'single_pkey';

SELECT	cols.COLUMN_NAME as column_name, 
	cols.DATA_TYPE as type, 
	cols.CHARACTER_MAXIMUM_LENGTH AS length, 
	CASE WHEN cols.IS_NULLABLE = 'No' THEN 0 ELSE 1 END as is_nullable,
	CASE WHEN pks.column_name IS NULL THEN NULL ELSE cols.ORDINAL_POSITION END AS primary_key,
	cols.ORDINAL_POSITION as position,
	pks.column_name as pks_column_name -- For testing
FROM INFORMATION_SCHEMA.COLUMNS cols
LEFT OUTER JOIN (SELECT kcu.COLUMN_NAME as column_name
	FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE as kcu
	INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS as tc
		ON kcu.CONSTRAINT_NAME = tc.CONSTRAINT_NAME
	WHERE tc.TABLE_NAME = @table_name
	AND CONSTRAINT_TYPE='PRIMARY KEY') as pks 
	ON pks.column_name = cols.COLUMN_NAME
WHERE TABLE_NAME = @table_name
ORDER BY cols.ORDINAL_POSITION


As the 'sa' user the [primary_key] column in the result set is always NULL when the owner if 'test_schema'.

Does anyone have any ideas that might help me out?
[If I've missed off some important piece of information then let me know - I'm sure I am just missing something obvious, but I just can't see it right now]


"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

The Second EuroCPian Event will be in Brussels on the 4th of September

Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!


GeneralRe: SQL permissions (uugghh!!) Pin
Steven Campbell12-Jul-04 7:54
Steven Campbell12-Jul-04 7:54 
GeneralRe: SQL permissions (uugghh!!) Pin
Colin Angus Mackay12-Jul-04 8:02
Colin Angus Mackay12-Jul-04 8:02 
GeneralListView wiht Dataset Pin
orpus11-Jul-04 19:37
orpus11-Jul-04 19:37 
GeneralRe: ListView wiht Dataset Pin
brdavid13-Jul-04 15:17
brdavid13-Jul-04 15:17 
Generalms access on web Pin
Asif Rehman11-Jul-04 17:43
Asif Rehman11-Jul-04 17:43 
GeneralRe: ms access on web Pin
Mike Ellison11-Jul-04 17:49
Mike Ellison11-Jul-04 17:49 
GeneralMysql Free download Pin
JawedVikia8010-Jul-04 19:16
JawedVikia8010-Jul-04 19:16 
GeneralRe: Mysql Free download Pin
Arjan Einbu11-Jul-04 3:10
Arjan Einbu11-Jul-04 3:10 
GeneralRe: Mysql Free download Pin
JawedVikia8013-Jul-04 21:49
JawedVikia8013-Jul-04 21:49 
GeneralRe: Mysql Free download Pin
Mike Ellison11-Jul-04 3:12
Mike Ellison11-Jul-04 3:12 
GeneralRe: Mysql Free download Pin
Steven Campbell11-Jul-04 5:39
Steven Campbell11-Jul-04 5:39 
GeneralRetrieve Data from Stored Proc Pin
mikasa9-Jul-04 11:09
mikasa9-Jul-04 11:09 
GeneralRe: Retrieve Data from Stored Proc Pin
Colin Angus Mackay9-Jul-04 11:52
Colin Angus Mackay9-Jul-04 11:52 
GeneralRe: Retrieve Data from Stored Proc Pin
mikasa9-Jul-04 12:10
mikasa9-Jul-04 12:10 
GeneralRe: Retrieve Data from Stored Proc Pin
rudy.net9-Jul-04 12:29
rudy.net9-Jul-04 12:29 
GeneralRe: Retrieve Data from Stored Proc Pin
mikasa12-Jul-04 5:46
mikasa12-Jul-04 5:46 
GeneralRe: Retrieve Data from Stored Proc Pin
Michael Potter12-Jul-04 8:56
Michael Potter12-Jul-04 8:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.