Category "sql-server"

Reset Identity Seed ('DBCC CHECKIDENT ... RESEED' is not working)

For my unit tests I have an automated process which builds a copy of a DB, table by table. I first of all run a SELECT INTO and add the primary key and any indi

sql server hint NOLOCK and ROWLOCK

I'm currently investigating an annoying problem on my website. We're giving away prizes regularly on the website, but to enter the competition people have to lo

Removing leading zeros from a string in SQL Server 2008 R2

I have a string representing a batch number of goods, for example "0000AZA001B". I only need the "AZA001B" part. How can I achieve that in SQL Compact?

How to create Temp table with SELECT * INTO tempTable FROM CTE Query

I have a MS SQL CTE query from which I want to create a temporary table. I am not sure how to do it as it gives an Invalid Object name error. Below is the whol

no mssql-jdbc_auth-8.2.1.x64 in java.library.path

I'm trying to connect to SQL DB in my Maven project, but keep getting following exception: "com.microsoft.sqlserver.jdbc.SQLServerException: This driver is no

How can I schedule a SQL job in Microsoft Azure SQL Database?

I have one SQL Agent maintenance job which checks the index fragmentation within a database and rebuilds indexes if required. This is running well in my test se

CREATE VIEW must be the only statement in the batch

I'm trying to make a view. So far, I have written this: with ExpAndCheapMedicine(MostMoney, MinMoney) as ( select max(unitprice), min(unitprice) from

Drop default constraint on a column in TSQL

I have a table with a column like this that is currently live: name NVARCHAR(128) NOT NULL DEFAULT '' I am altering the column like this to make it nullable:

UNDOCUMENTED FEATURE when SELECT in VARCHAR with trailing whitespace SQL Server

I hope this is an interesting puzzle for an SQL expert out there. When I run the following query, I would expect it to return no results. -- Create a table vari

ASP.NET Core: Error while Updating Migration (Database first approach)

I have created an application in .NET Core where I am trying with database first approach. I was able to add Migration using "Add-Migration InitialCreate" but

MAUI Blazor Android Sql Connection

I am experimenting with Maui Blazor. I want to connect my application with an SQL server database. Therefore I used a simple Sql Connection String. When I test

How to create the linked server for SQL Server 2008 where we have the database from 2000 and 2005

Currently I am working on SQL Server 2000,2005 & 2008, my requirement is like, the database available in SQL Server 2000 & 2005 will be available in 200

Join two tables and return only one row from second table

I have two tables. Both tables contains an ID that can be used to join them together. However, table 2 can have more than one row for the same ID. Table 1 will

SQL query to determine that values in a column are unique

How to write a query to just determine that the values in a column are unique?

Correct use of transactions in SQL Server

I have 2 commands and need both of them executed correctly or none of them executed. So I think I need a transaction, but I don't know how to use it correctly.

mssql isn't an available database backend or couldn't be imported

I'm following this guide. Mssql-django and I have Django version 3.2.12 I already installed mssql-django 1.1.1 I also have pyodbc 4.0.32 modified my settings.py

How to insert into a table that specifies a DEFAULT value for every column?

I have a table where all columns are auto-populated whenever an insertion happens: CREATE TABLE … ( ItemID INT NOT NULL IDENTITY(…

ALTER DATABASE failed because a lock could not be placed on database '<db_name>'. Try again later

I really don't care what I do with this test database...it's for sandbox testing (attached to a production server instance)! All I'm trying to do is KILL all co

Guid.NewGuid() is returning duplicate values when used in a Parallel.For loop

I have an application that is hitting an API. As such, it does a query for all ID's in the object, and then has to query each item one at a time per ID. I'm d

Run xp_create_subdir without admin privilidges

The Point: I want to be able to create a directory on the filesystem through a non-sysadmin SQL user. I'm creating a web front-end for a deployment script whi