Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can sp_pkeys be used as a function in T-SQL?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00796849
Message ID:
00796855
Views:
57
This message has been marked as the solution to the initial question of the thread.
Can you use INFORMATION_SCHEMA instead?
SELECT * FROM   INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
	JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu
		ON tc.CONSTRAINT_name = ccu.CONSTRAINT_name
	WHERE CONSTRAINT_type = 'PRIMARY KEY'
>Hi. I'm attempting to make use of a SP from within a SQL statement. What I would like to return is a table of table names that have a trigger associated as well as the primary key's column name associated with the table. The problem I am having is retrieving the PK for the retrieve tables.
>
>Here's what I have so far, but as you can see with the portion immediately following the sp_pkeys SP, it is incomplete and destined for failure.
>
>SELECT sysobjects.name, sp_pkeys sysobjects.name
>FROM sysobjects
>WHERE (id IN
> (SELECT DISTINCT parent_obj FROM sysobjects WHERE xtype = 'TR'))
>ORDER BY name
>
>Any suggestions?
>
>Doug
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform