Using a temprary table as an array
This script is used to extract from a temprary table with long string all elements in an array formatlength of 15 chars is assumed.
2002-08-01
626 reads
This script is used to extract from a temprary table with long string all elements in an array formatlength of 15 chars is assumed.
2002-08-01
626 reads
Smooshing - The act of removing all non-alphanumeric characters from a string. We have found several areas of our application where we need to perform cleaning on strings. The following is a SQL function which can be used to remove any non-alphanumeric characters. To use the function create the script and then SELECT dbo.fn_SmooshIt('B?\RU.,C>}E') will […]
2002-07-26
555 reads
Instead of interactively running profiler, you can use built in stored procedures to obtain the same results. You can even schedule the execution of the trace and output to a designated output file.
2002-07-25
708 reads
This script will run through the foreign keys on tables to produce a hierarchy of the tables in a database.This is useful when you need to purge and repopulate test databases with foreign key contraints
2002-07-24
2,124 reads
Given database, owner, table, and column names, this procedure returns one from among several column attributes such as type definition, defaults, and other types of constraints. E.g., to retrieve the type definition of the 'pubs' database's 'author.address':DECLARE @attrib VARCHAR (500) , @msg VARCHAR (8000)EXEC p_get_column_attribute 'TYPEDEF' […]
2002-07-24
137 reads
Scalar function 'f_contains' counts the number of times the first argument occurs within the second argument.Given: @arg1, @arg2 (both VARCHAR), @cnt INTSELECT @cnt = dbo.f_contains (@f_search_for = @arg1 , @f_container = @arg2)
2002-07-22
391 reads
Scalar function 'f_delimited' slices out of a passed-in string, from a specified position inside the string, that segment of it which is delimited on one or both sides by a specified delimiter.Example: Print out a segment of a 'syscomments.text' column for a stored procedure 'p_proc', representing a line of code (i.e., the segment of 'syscomments.text' […]
2002-07-22
121 reads
Procedure 'p_find_string' allows users to specify any database on a server in searching for a specified character string. Supported for string-searching: table columns, view columns, trigger, function, and procedure code. Produces a report showing: object type, owner, object name, column id (for tables and views) or what line number (for triggers, functions, and procedures), and […]
2002-07-22
147 reads
Let's say you have 2 tables: a Contacts table and a PhoneNumbers table (which stores all the phone numbers for each contact). You are asked to write a query that returns each contact's name and a comma-delimited string of phone numbers for each contact, something like this:FirstName LastName PhoneNumbers--------- -------- --------------------------John […]
2002-07-22
1,035 reads
Using a Having clause I eliminate getting the EVEN rows and getting ovly the odd primary keysBy using Having (count(*) %2) = 0 I will get the even and not the odd.
2002-07-20
300 reads
By Vinay Thakur
Following up on my Part 1 baseline, the journey from 2017 onward changed how...
By Brian Kelley
In cryptography, the RSA and ECC algorithms which we use primarily for asymmetric cryptography...
By Steve Jones
In today’s world, this might mean something different, but in 2010, we had this...
I've got a table with 186,703,969 rows, about 300GB of data. There are several...
I created a SQL Database in Azure Portal but I've just noticed it also...
Comments posted to this topic are about the item An Unusual Identity
What values are returned when I run this code?
CREATE TABLE dbo.IdentityTest2
(
id NUMERIC(10,0) IDENTITY(10,10) PRIMARY KEY,
somevalue VARCHAR(20)
)
GO
INSERT dbo.IdentityTest2
(
somevalue
)
VALUES
( 'Steve')
, ('Bill')
GO
SELECT top 10
id
FROM dbo.IdentityTest2 See possible answers