Miscellaneous

Technical Article

Smooshing String Function

  • Script

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 […]

You rated this post out of 5. Change rating

2002-07-26

539 reads

Technical Article

String-search on objects in a specified database

  • Script

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 […]

You rated this post out of 5. Change rating

2002-07-22

135 reads

Technical Article

Slice out string from within specified delimiters

  • Script

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' […]

You rated this post out of 5. Change rating

2002-07-22

106 reads

Technical Article

Count # occurrences of one string inside another

  • Script

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)

1 (1)

You rated this post out of 5. Change rating

2002-07-22

375 reads

Technical Article

Using UDFs to avoid cursors

  • Script

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      […]

You rated this post out of 5. Change rating

2002-07-22

998 reads

Technical Article

sp_dir - Procedure to list database objects

  • Script

Lists objects from database. Similar to 'dir' command from DOS 🙂Typical usage sp_dir 't' 'order*', 1     - returns list of all tables whose name start with 'order' plus their columns and data typessp_dir 'p' 'custom*_sp' -  returns list of all stored procedures whose name start with 'custom' and end up with '_sp'For list of […]

You rated this post out of 5. Change rating

2002-07-19

477 reads

Blogs

Using Flyway Prepare for State-Based Deployments

By

One of the neat enhancements made to Flyway was the addition of state-based workflows...

How I Migrated to Azure PostgreSQL Flex from Single Server

By

I did a couple of posts previously on dumping/restoring Azure PostgreSQL databases and also...

Have a Plan for Your Personal Downtime

By

Most of us know that spending a lot of time on social media and...

Read the latest Blogs

Forums

PowerQuery.... don't meet SSIS

By pietlinden

I have a powerQuery that reads and transforms a table in a PDF.  Works...

Count of Total Appointments within 30 days of each Appointment Date

By Reh23

Good Afternoon. I have a Table where each Record: 1) Represents an Appointment. 2)...

Reporting Services in Managed Instance

By Arjun SreeVastsva

Hi , one of my on-premises servers one server is having databases and one...

Visit the forum

Question of the Day

Hash Joins IV

What is a hash bailout?

See possible answers