|
|
|
The following code snippet will produce comma seperated list of column name of a specified table from Northwind Database. |
Click here to copy the following block | DECLARE @tblName VARCHAR(100) SET @tblName = 'Northwind.dbo.Customers'
SELECT Stuff ( ( SELECT N', ' + name FROM sys.columns pc WHERE pc.object_id = OBJECT_ID(@tblName) FOR XML PATH(''),TYPE ).value('text()[1]','nvarchar(max)'),1,2,N'' ) AS ColumnList |
Returns The following output |
Click here to copy the following block | ColumnList
CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|