background preloader

T-Sql

Facebook Twitter

Sql server - Turning a Comma Separated string into individual rows. Searching for Strings in SQL Server Databases. Sometimes, you just want to do a search in a SQL Server database as if you were using a search engine like Google.

Searching for Strings in SQL Server Databases

Besides the obvious Full-Text search, there are plenty of techniques for finding that pesky data that resists the normal SELECT blandishments. Phil Factor describes some alternative techniques. For most of the time you will get adequate powerful searches from a well-normalized database that has all possible constraints and indexes. Just occasionally, usually when you’re searching through text, or you’ve inherited the work of someone whose major talents lie in other areas of life, you need other magic. This article is about some of the SQL magic that might be required. The first type of search I’ll refer to is the ‘Brute-force’ search, where performance isn’t the primary concern. We’ll tackle both types of searches in this article, but not Full-Text Search (FTS). Ad-hoc Brute-force searches of databases. The blunt instrument – Search anywhere in a query result begin end example: Xml - SQL Server SELECT to JSON function.

How to Execute and Monitor an Agent Job Using T-SQL in SQL Server 2005/2008. In SQL Server 2005 and 2008 it's possible to start an agent job with T-SQL syntax.

How to Execute and Monitor an Agent Job Using T-SQL in SQL Server 2005/2008

This is frequently useful. For example, you may have a job that you'd like to have an outside application invoke. Jobs can also be used to execute SSIS packages. Using T-SQL to execute a job that runs an SSIS package is a way to provide an application access to an SSIS package. One potential hangup with running agent jobs from a stored procedure is that control is returned immediately to the SQL that runs the job. I'll show you how to determine the status of a job that has been invoked, and return upon completion. First, some background. Beyond SoundEx - Functions for Fuzzy Searching in MS SQL Server. Sunday, January 11, 2009 12:08 AM, Filed Under SQL C# SQLCLR In this post: Quite often we come across a requirement where we may need to perform some sort of fuzzy string grouping or data correlation.

Beyond SoundEx - Functions for Fuzzy Searching in MS SQL Server

For example, we may want to correlate the customer records of a database by identifying records that are similar but not necessarily exactly the same (due to spelling mistakes for example). Obviously a simple group by, will not successfully group such data. Fuzzy-String Search: Find misspelled information with T-SQL. How many times has a user told you that they entered a contact into your CRM system, and now they cannot locate it by name?

Fuzzy-String Search: Find misspelled information with T-SQL

Then, after you help them locate it by some other means, it turns out that either the original entry or the search term was misspelled? Would you like your search to be able to suggest alternates when a key word is misspelled? When "fuzzy" string matching is most helpful Whether it's misheard, mistyped, poorly scanned, or copied and pasted from a bad source, misspelled information is a common irritant to the user. If a user can't find the record they're looking for quickly, they will probably enter it again. T sql find column name in database in any table using sql server tsql system query. Upsss...

t sql find column name in database in any table using sql server tsql system query

Something went wrong and Google Ads on our website did not display. Google ads sponsor FREE content on our website and without them it would not exist. How to fix the problem? Check if the Google Search display any ads by searching the term Business Intelligence If ads don't display, try different search terms and if there no ads then there might be a problem with your browser. If you made changes to your browser behaviour then undoing them will help. Close Take care Katie & Emil Well done! Access our website's FREE content for FREE! Selecting Rows Randomly from a Large Table. If you use Microsoft SQL Server 2000, you likely have run into the following problem: You want to select a random sampling of rows from a large table with lots of rows, but you are unsure of how to do so.

Selecting Rows Randomly from a Large Table

Having a random sampling of rows can be useful when you want to make a smaller version of the table or if you want to troubleshoot a problem by seeing what kinds of rows are in the table. To get a random sampling, you might be tempted to select the top n rows from the table. However, this sample is not random, and the first n rows are not necessarily representative of the whole table.

Other solutions exist that involve adding columns to the tables; however, adding columns is not always possible or practical. The standard way to grab random rows from a small table is to use a query such as the following: SELECT TOP 10 PERCENT * FROM Table1 ORDER BY NEWID() The key here is the NEWID function, which generates a globally unique identifier (GUID) in memory for each row.

Table 1. Figure 1. The EXCEPT and INTERSECT Operators in SQL Server. The UNION, EXCEPT and INTERSECT operators of SQL enable you to combine more than one SELECT statement to form a single result set.

The EXCEPT and INTERSECT Operators in SQL Server

The UNION operator returns all rows. The INTERSECT operator returns all rows that are in both result sets. The EXCEPT operator returns the rows that are only in the first result set but not in the second. Simple? Rob Sheldon explains all, with plenty of examples. Quite often, you’re faced with the task of comparing two or more tables, or query results, to determine which information is the same and which isn't. Enter the INTERSECT and EXCEPT operators. The illustration shows how the INTERSECT operator returns data that is common to both results set; the common data is represented by the area where the two circles intersect. To return the data in Set A that doesn’t overlap with B, use A EXCEPT B.

The differences between the INTERSECT and EXCEPT operators and how to use each of them will become clearer as we work through the examples in the article. Rolling up multiple rows into a single row and column for SQL Server data. How to perform a SQL Server distributed query with OLAP Server. This article describes how to perform a SQL Server distributed query to retrieve data from an OLAP Services (or Analysis Services) cube.

How to perform a SQL Server distributed query with OLAP Server

With Microsoft SQL Server version 7.0, you can perform queries against OLE DB providers. To do this, you can: Use the OPENQUERY or the OPENROWSET Transact-SQL functions.