How to automatically generate unique id in SQL like UID12345678?

The only viable solution in my opinion is to use an ID INT IDENTITY(1,1) column to get SQL Server to handle the automatic increment of your numeric value a computed, persisted column to convert that numeric value to the value you need So try this: CREATE TABLE dbo.tblUsers (ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY … Read more

Can’t create stored procedure with table output parameter

Table parameters are readonly. You cannot select into them. Use Table-Valued Parameters: Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine. And Table-Valued Parameters: You cannot return data in a table-valued … Read more

Wait on the Database Engine recovery handle failed!! SQL Server 2012 installation

Ok, after 6 hours of struggle and ‘googling’ I could finally get this work. The problem was due to some account name conflict. Here are the steps I followed to set it right 1) Un-installed the SQLserver 3) Re-installed it back with following changes In the server configuration section, I changed the account name details … Read more

Try_Convert for SQL Server 2008 R2

When using XML in SQL Server you can try to cast to a data type and receive null values where the cast fails. declare @T table ( Col varchar(50) ) insert into @T values (‘1’), (‘1.1’), (‘1,1’), (‘1a’) select cast(” as xml).value(‘sql:column(“Col”) cast as xs:decimal ?’, ‘decimal(28,10)’) as Col from @T Result: Col ————- 1.0000000000 … Read more