sp_lock with order by and object name
A kind of sp_lock with an ORDER BY possibility. It gives also the name of the locked object (table) if executed in the same database.
2004-10-22 (first published: 2004-07-26)
712 reads
A kind of sp_lock with an ORDER BY possibility. It gives also the name of the locked object (table) if executed in the same database.
2004-10-22 (first published: 2004-07-26)
712 reads
This code will show rows from 17th and then next 3 ordered by name from table authors in database pubs. Table must have primary key and of course ordered column. You can change value 'from' in line 'SET ROWCOUNT 17' and value 'next' (how many rows)in line SELECT TOP 3. It is good to show […]
2004-10-21 (first published: 2004-07-29)
198 reads
integer IP-address converted to varchar dot-notationUsage SELECT dbo.IPNumberToString(-2037012288)
2004-10-20 (first published: 2004-07-29)
430 reads
This is a modification to Automate Audit Trigger Generation at http://www.sqlservercentral.com/scripts/contributions/1073.asp by walkerjet. The changes were made to accommodate tables using different types for their primary keys, (i.e. int, smallint, char, etc.), add the ModifiedById and DTStamp columns, exclude legacy tables that do not have a primary key defined, exclude fields of type text, ntext, […]
2004-10-19 (first published: 2004-07-29)
358 reads
After seeing a thread in the forums about converting a Julian date to Gregorian, I decided to write these functions. There are two functions in the script, getJulian and getGregorian. getJulian accepts a datetime parameter and returns the Julian date as an integer. getGregorian accepts an integer and returns the Gregorian date as datetime. A […]
2004-10-18 (first published: 2004-08-03)
1,095 reads
This User defined Function will provide you the facility of fetching the nth Value from a Delimited string. The Parameter for the function which you have to pass is, the Delimited String, the Delimiter of the string, nth Position of the string. In this function , you can dynamically change the Delimiter as well as […]
2004-10-15 (first published: 2004-08-04)
1,434 reads
If you set up a default on a column AFTER data has been entered, then this procedure will apply the default to all NULL values within that column. Limitations: It only works with numeric values right now.You will also need the INSTR function, which you can also get from this site.This is my first […]
2004-10-13 (first published: 2004-07-22)
94 reads
There are times when you have mulitple job failures and need to find out in a quick way which jobs/steps failed and what their rerun statuses are. This script creates a stored procedure in the msdb db to help you find out the statuses of these jobs.
2004-10-12 (first published: 2004-07-21)
144 reads
This is a utility proc that I use a lot for datawarehouse transformation/load processing. This is a generic proc for resequencing an integer column in sorted order within a given key combination.Note that 'key' is used here in a general context and not specific, that is there doesn't have to be any keys or indexes […]
2004-10-12
85 reads
Modification of the script entitled "Counting occurrences in a string" by thomasun.This version, packaged as a UDF, is not limited to searching for single characters - substrings can be counted.
2004-10-11 (first published: 2004-07-20)
278 reads
By Steve Jones
Fear is fueled by a lack of imagination. The antidote to fear is not...
The slidedeck and the SQL scripts for the session Indexing for Dummies can be...
By Chris Yates
Change is not a disruption in technology; it is the rhythm. New frameworks appear,...
We have a report that has multiple tables that list the top 15 performers...
We have a tool called DB Moto that reads journals (like t-logs) and replicates...
Comments posted to this topic are about the item Don't Forget About Financial Skills
The DBCC CHECKIDENT command is used when working with identity values. I have a table with 10 rows in it that looks like this:
TravelLogID CityID StartDate EndDate 1 1 2025-01-11 2025-01-16 2 2 2025-01-11 2025-01-16 3 3 2025-01-11 2025-01-16 4 4 2025-01-11 2025-01-16 5 5 2025-01-11 2025-01-16 6 6 2025-01-11 2025-01-16 7 7 2025-01-11 2025-01-16 8 8 2025-01-11 2025-01-16 9 9 2025-01-11 2025-01-16 10 10 2025-01-11 2025-01-16The docs for DBCC CHECKIDENT say this if I run with only the table parameter: "If the current identity value for a table is less than the maximum identity value stored in the identity column, it is reset using the maximum value in the identity column. " I run this code:
DELETE dbo.TravelLog WHERE TravelLogID >= 9 GO DBCC CHECKIDENT(TravelLog, RESEED) GO INSERT dbo.TravelLog ( CityID, StartDate, EndDate ) VALUES (4, '2025-09-14', '2025-09-17') GOWhat is the identity value for the new row inserted by the insert statement above? See possible answers