Useing Information_Schema.Columns is the best out of those. This is because it returns results in a readable format. Below is how you can do this;
SELECT * FROM information_schema.columns WHERE Table_Name = 'YourTableName'
Alternately you can use SP_Columns as well, usage is as below;
EXEC sp_Columns 'YourTableName'
In addition to this if you want to say get all the columns in a database which has a particular name or part of the name in it, this can be also achieved using a script like this;
SELECT * FROM information_schema.columns WHERE Column_Name LIKE '%url%'
This will return all columns which are having url as part of the name.
No comments:
Post a Comment