79
Views
1
Comments
SQL Unlimited records in SQL Query - SET IDENTITY_INSERT
Question
Application Type
Reactive

My case is that I had to fix a bug from legacy, its a create operation, for that my coleague make it like this:
1. SET IDENTITY_INSERT {Table_name} ON
2. Do Create 
3. SET IDENTITY_INSERT {Table_name} OFF
The things is in the SQL 1 & 3 he created, OutSystem consider that query as a "SQL Unlimited records in SQL Query" tech debt. In a normal case when there is SELECT query I can use a SELECT TOP 10000 to avoid that, but in this case its a SET query so I cant use TOP, so I cant resolved this tech dept. Anyone know how to fix it?, Please help!!!

UserImage.jpg
Craig Rodrigues

@Le Duc Huy Hello, Not sure why you're doing it this way , this is just very bad practice to have you turn on Identity values before any insert then back off again.

Anyways,to resolve your technical dept issue,  your query should look something like this and you have to tweak the sql advance query to return the Table_name Identifier.

SET IDENTITY_INSERT {Table_name} ON
Do Create 
SET IDENTITY_INSERT {Table_name} OFF
select top 1 SCOPE_IDENTITY()

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.