Miscellaneous

Technical Article

faster dbo.ufn_vbintohexstr - varbinary to hex

  • Script

Here's an alternative to Clinton Herring's ufn_vbintohexstr which should be much faster with large varbinary values. First, in his original version, the inner-loop CASE statements can be replaced with this: select @value = @value + CHAR(@vbin/16+48+(@vbin+96)/256*7) +CHAR(@vbin&15+48+((@vbin&15)+6)/16*7) How does it work? By adding 6 to a hex-digit in (@vbin&15), you have a value from 16 […]

You rated this post out of 5. Change rating

2006-12-20 (first published: )

123 reads

Technical Article

HexToInt

  • Script

Challenged by Hans Lindgren's stored procedures of the same name, I created this. Note that it produces strange results on non-hexadecimal strings, overflows at 0x80000000, and could have issues with byte-ordering on some architectures.How does it work? Well, the distance between one after '9' (':') and 'A' is 7 in ASCII. Also, if I subtract […]

You rated this post out of 5. Change rating

2006-12-15 (first published: )

211 reads

Technical Article

HexToSmallInt

  • Script

Hans asked if it could be faster. This is about 10% faster; not much. His is admittedly more readable, and mine will act very strangely with invalid hex digits.How does it work? I'm converting the string '1234' to the value 0x31323334 (for example), then subtracting '0000' so that it is 0-based in each byte (CONVERT(INT,0x30303030) […]

You rated this post out of 5. Change rating

2005-05-16 (first published: )

142 reads

Technical Article

SQL Blocking and Blocked Proc + Notifi - Part2

  • Script

Based on the script by Paul Delmarche ( http://www.sqlservercentral.com/scripts/contributions/1482.asp ).Updated to now include the spid, username, blocked and blocking SQL statements in the email (still logged to table).Schedule the procedure to run at defined intervals (I use 2 minutes)

5 (1)

You rated this post out of 5. Change rating

2005-05-12 (first published: )

1,430 reads

Technical Article

usp_get_all_stats_date

  • Script

This script gathers stats_date and index information for all of the current database. Please feel free to modify it as it is made up of components that are available on this site here- http://www.sqlservercentral.com/scripts/contributions/97.aspand a BOL entry for stats_date.I needed this information and thought I would share it.

You rated this post out of 5. Change rating

2006-07-17 (first published: )

556 reads

SQLServerCentral Article

Selecting a Web Host for your SQL Server Driven Website Part 2

  • Article

Many of us have SQL Servers at work that we learn on, test with work, etc. But getting your own SQL Server for a website can be a tricky thing. Especially on a budget. Or maybe your company wants to have their website hosted. Before you spend any hard earned money, read part 2 of this two part series by Jon Reade on what to look for when setting up a SQL Server hosting company.

You rated this post out of 5. Change rating

2005-04-20

5,377 reads

Technical Article

User-Defined string Functions Transact-SQL

  • Script

GETWORDCOUNT, GETWORDNUM, AT, RAT, OCCURS,CHRTRAN, STRFILTER, PADC, PADR, PADL, PROPER, RCHARINDEX etc. AT, PADL, PADR, CHRTRAN, PROPER are similar to functions Oracle PL/SQL INSTR, LPAD, RPAD, TRANSLATE, INITCAP. In my humble opinion, it will be convinient to apply such functions for writing of stored procedures and User-Defined Functions on Transact-SQL. Please, download the file http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,27115

You rated this post out of 5. Change rating

2006-01-10 (first published: )

1,554 reads

Blogs

The CDO’s Playbook for AI Driven Decision Making

By

The New Arena of Leadership The role of the Chief Data Officer is no...

sp_snapshot – The easy way to take database snapshots of one or more databases – V3.0

By

Presenting you with an updated version of our sp_snapshot procedure, allowing you to easily...

SELECT *

By

SELECT * feels convenient, but in SQL Server it bloats I/O, burns network bandwidth,...

Read the latest Blogs

Forums

The Maximum Value in the Identity Column

By Steve Jones - SSC Editor

Comments posted to this topic are about the item The Maximum Value in the...

combining a param value with widcards in a foreach loop files property

By stan

Hi, it isnt clear from the web if something like this should work as...

Extract sql data in psh

By Sqladmin1

# Load ImportExcel module Import-Module ImportExcel -ErrorAction Stop # File paths $outFile = "C:\Reports\SQLReport.xlsx"...

Visit the forum

Question of the Day

The Maximum Value in the Identity Column

I have a table with this data:

TravelLogID CityID StartDate  EndDate
1           1      2025-01-01 2025-01-06
2           2      2025-01-01 2025-01-06
3           3      2025-01-01 2025-01-06
4           4      2025-01-01 2025-01-06
5           5      2025-01-01 2025-01-06
I run this code:
SELECT IDENT_CURRENT('TravelLog')
I get the value 5 back. Now I do this:
SET IDENTITY_INSERT dbo.TravelLog ON
INSERT dbo.TravelLog
(
    TravelLogID,
CityID,
    StartDate,
    EndDate
)
VALUES
(25, 5, '2025-09-12', '2025-09-17')
SET IDENTITY_INSERT dbo.TravelLog OFF
I now run this code.
DBCC CHECKIDENT(TravelLog)
GO
INSERT dbo.TravelLog
(
    CityID,
    StartDate,
    EndDate
)
VALUES
(4, '2025-10-14', '2025-10-17')
GO
What is the value for TravelLogID for the row I inserted for CityID 4 and dates starting on 14 Oct 2025?  

See possible answers