Tag sql

Insert default value SQL primary key

I have a table in Microsoft SQL Server where insert or updates isn’t possible. Table is only responsible to increment a unique id. The table looks like this: CREATE TABLE [dbo].[CustomerOrderNumbers]( [customerOrderNumberId] [int] IDENTITY(1,1) NOT NULL, [createdOn] [datetime] NOT NULL,…

View current sql queries on MSSQL database

To view current sql queries running on sql database you can use this sql script to get current query and elapsed time. SELECT sqltext.TEXT, req.session_id, req.status, req.command, req.cpu_time, req.total_elapsed_time FROM sys.dm_exec_requests req CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext I have only…