Simple, yet i keep forgetting so to keep me reminded here it is. To reset identity to a table, so that everytime the surrogate keys start with 1 use the following command
DBCC CHECKIDENT('DimAssetUser', RESEED, 0)
This resets the identity to where its starting point, for the DimAssetUser table.
Showing posts with label Query. Show all posts
Showing posts with label Query. Show all posts
Tuesday, October 14, 2008
Thursday, July 10, 2008
Select statement when table value has square brackets

I had to query a customer table which has customer name enclosed in square brackets.
I tried this first
SELECT * FROM JCustomer WHERE FirstName LIKE '%[%]' -- no rows returned
SELECT * FROM JCustomer WHERE FirstName LIKE '%[%]' -- no rows returned
Then i tried this,
SELECT * FROM JCustomer WHERE FirstName LIKE ' [ [ ]% ' -- this return records which start with square brackets. The trick is to enclose the search string within a square bracket.
SELECT * FROM JCustomer WHERE FirstName LIKE ' [ [ ]% ' -- this return records which start with square brackets. The trick is to enclose the search string within a square bracket.
Subscribe to:
Posts (Atom)