How can I get column names from a table in SQL Server?

You can obtain this information and much, much more by querying the Information Schema views. This sample query: Can be made over all these DB objects: CHECK_CONSTRAINTS COLUMN_DOMAIN_USAGE COLUMN_PRIVILEGES COLUMNS CONSTRAINT_COLUMN_USAGE CONSTRAINT_TABLE_USAGE DOMAIN_CONSTRAINTS DOMAINS KEY_COLUMN_USAGE PARAMETERS REFERENTIAL_CONSTRAINTS ROUTINES ROUTINE_COLUMNS SCHEMATA TABLE_CONSTRAINTS TABLE_PRIVILEGES TABLES VIEW_COLUMN_USAGE VIEW_TABLE_USAGE VIEWS

SQL – The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

I have faced the same problem a week ago. The problem is with the time zone setting. Specify in other formats like mm/dd/yyyy (usually works). Specifying the date as 30/12/2013 resulted in the error for me. However, specifying it as mm/dd/yyyy format worked. If you need to convert your input the you can try looking into the CONVERT method. … Read more

How to group by month from Date field using sql

I would use this: This will group by the first of every month, so will give ‘20130101’. I generally prefer this method as it keeps dates as dates. Alternatively you could use something like this: It really depends what your desired output is. (Closing Year is not necessary in your example, but if the date range … Read more

Why use a READ UNCOMMITTED isolation level?

This isolation level allows dirty reads. One transaction may see uncommitted changes made by some other transaction. To maintain the highest level of isolation, a DBMS usually acquires locks on data, which may result in a loss of concurrency and a high locking overhead. This isolation level relaxes this property. You may want to check … Read more

How to upsert (update or insert) in SQL Server 2005

Try to check for existence: You could easily wrap this into a stored procedure and just call that stored procedure from the outside (e.g. from a programming language like C# or whatever you’re using). Update: either you can just write this entire statement in one long string (doable – but not really very useful) – or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)