Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Find the DataType and IsNullable Fields From the Q

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2009-10-07 : 13:15:12
Hi,

Let's say I have a simple query:

select FirstName, LastName, MiddleName from Customers

How can I find out from the Query above that the MiddleName field is nullable and allows null.

The actual query is little complicated with views and stuff but how can I achieve the above.

Mohammad Azam
www.azamsharp.net

X002548
Not Just a Number

15586 Posts

Posted - 2009-10-07 : 13:16:56
sp_help Customers

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

azamsharp
Posting Yak Master

201 Posts

Posted - 2009-10-07 : 13:19:51
sp_help Customers will give me schema information related to Customers table. What I want is the query results to indicate the schema of the tables used in the query.

select c.FirstName, c.LastName, c.MiddleName, o.OrderName, o.Quantity from Customers c join Order o on c.CustomerId = o.OrderId

In the above query I want to know that if the OrderName, Quantity is allow nullable in the database. Is that possible?

Mohammad Azam
www.azamsharp.net
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-10-07 : 14:28:23
I don't know how to do it for a query, but if you know the table names you can use the INFORMATION_SCHEMA views:
SELECT *
FROM INFORMATION_SCHEMA.Columns
WHERE TABLE_NAME IN ('Customers', 'Order')
Go to Top of Page
   

- Advertisement -