Update Collation of all fields in database on the fly

Just in case anyone looking at this is using SQL server 2008, i had to make a couple modifications: SELECT ‘ALTER TABLE [‘ + sys.objects.name + ‘] ALTER COLUMN [‘ + sys.columns.name + ‘] ‘ + sys.types.name + CASE sys.types.name WHEN ‘text’ THEN ‘ ‘ ELSE ‘(‘ + RTRIM(CASE sys.columns.max_length WHEN -1 THEN ‘MAX’ ELSE … Read more

Calculate size in megabytes from SQL varbinary field

Use DATALENGTH to retrieve the number of bytes and then convert, like this: SQL Fiddle MS SQL Server 2017 Schema Setup: CREATE TABLE supportContacts ( id int identity primary key, type varchar(20), details varchar(30) ); INSERT INTO supportContacts (type, details) VALUES (‘Email’, ‘[email protected]’), (‘Twitter’, ‘@sqlfiddle’); Query 1: select *, gigabytes / 1024.0 as terabytes from … Read more

How to add Sysadmin login to SQL Server?

sysadmin is a server role; it can be applied to any login. When installing SQL Server a login sa is created with this privilege; you can specify the password when you’re installing SQL Server. Or you can create your own login: CREATE LOGIN adminuser WITH PASSWORD = ‘ABCDegf123′; GO EXEC master..sp_addsrvrolemember @loginame = N’adminuser’, @rolename … Read more

Default instance name of SQL Server Express

When installing SQL Express, you’ll usually get a named instance called SQLExpress, which as others have said you can connect to with localhost\SQLExpress. If you’re looking to get a ‘default’ instance, which doesn’t have a name, you can do that as well. If you put MSSQLServer as the name when installing, it will create a … Read more

Help troubleshooting SqlException: Timeout expired on connection, in a non-load situation

Not Enough Memory This is very likely a Memory problem, perhaps aggravated or triggered by other things, but still inherently a memory problem. there are two other (less likely) possibilities, that you should check and eliminate first (because it is easy to do so): Easy To Check Possibilities: You may have “Auto Close” enabled: Auto … Read more

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