SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName'?
Here are some pro tips for working with T-SQL:
Use SET NOCOUNT ON: This statement stops the message indicating the number of rows affected by a query, which can improve performance.
Avoid using SELECT *: Instead of selecting all columns, specify only the columns you need. This reduces the amount of data returned and can improve performance.
Use stored procedures: Stored procedures can be pre-compiled and cached, which can improve performance. They can also simplify complex queries and make them easier to maintain.
Use indexing: Indexes can improve query performance by allowing the database engine to quickly find the data it needs.
Use parameterized queries: Parameterized queries can improve performance by reusing execution plans and reducing the risk of SQL injection attacks.
Use temporary tables wisely: Temporary tables can be useful, but they can also slow down performance if they are not used properly. Avoid creating temporary tables in loops or for small amounts of data.
Use transactions: Transactions ensure that a group of SQL statements are treated as a single unit of work, which can help maintain the consistency of data.
Use common table expressions (CTEs): CTEs can simplify complex queries and make them easier to read and maintain.
Use window functions: Window functions allow you to perform calculations across multiple rows, which can be useful for tasks like ranking or running totals.
Monitor performance: Keep an eye on query performance and use tools like SQL Profiler to identify bottlenecks and optimize your queries.