How to ALTER multiple columns at once in SQL Server?

I need to ALTER the data types of several columns in a table. For a single column, the following works fine: ALTER...

How to check if a database exists in SQL Server??

What is the ideal way to check if a database exists on a SQL Server using TSQL? It seems multiple approaches to impl...

Adventure Works Explanation?

I've been looking at Microsoft's Adventure Works 2012 database. I'd be very interested if there's any information ex...

How to check if a column is empty or null using SQL query select statement??

How do I check if a column is empty or null using a SQL select statement? For instance, if I want to check: select...

SQL Server AS statement aliased column within WHERE statement?

I want to execute a query in which I rename one of the columns using the 'AS' statement and reuse that aliased colum...

What are the best practices in writing a sql stored procedure?

I found that SQL stored procedures are very interesting and useful. I have written stored procedures but i want to w...

How to update Identity Column in SQL Server??

I have SQL Server database and I want to change the identity column because it started with a big number 10010 and i...

how to select rows based on distinct values of A COLUMN only?

I need to query a table in order to return rows, but I am not able to query the table correctly. Here is my table vi...

How to drop a table if it exists??

The table name is Scores. Is it correct to do the following? IF EXISTS(SELECT * FROM dbo.Scores) DRO...

varbinary to string on SQL Server?

How to convert a column value from varbinary(max) to varchar in human-readable form? ...

Comparing two bitmasks in SQL to see if any of the bits match?

Is there a way of comparing two bitmasks in Transact-SQL to see if any of the bits match? I've got a User table with...

How to convert Seconds to HH:MM:SS using T-SQL?

The situation is you have a value in Seconds (XXX.XX), and you want to convert to HH:MM:SS using T-SQL. Example: ...

Insert results of a stored procedure into a temporary table?

How do I do a SELECT * INTO [temp table] FROM [stored procedure]? Not FROM [Table] and without defining [temp table]...

UPDATE statement with multiple WHERE conditions?

I'm trying to run an UPDATE query in Access with different WHERE conditions: UPDATE Table1 SET [Ticker] = "TXSFI" W...