Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

SQL Scripts & Samples

Posted Jul 19, 2001

DynamicSearch_UsingEXEC.txt

By DatabaseJournal.com Staff



Here's a UDF function for SQL 2000 that will save you datetime headaches when passing datetime variables into your SQL Procedures. The function converts any datetime field to ensure that you don't lose data for the last day to be included.

Here's a simple and straightforward stored procedure that searches a column in a table for words. It can also be easily modified to return all columns rather than just one. The SP was created for SQL Server 2000 but should also work in SQL 7.

Function: Allows to bring back records that contains all words supplied to it. (up to 255 chars total)

The script uses:

  • EXECute to create a dynamic select statement
  • Like and wildcards
  • WHILE loop to construct the dynamic where statement
  • and a couple other simple items everybody asks about
=======================================================
Example: sp00_QueryColumn 'jump the gator','GatorColumn','GatorTable'

would search the column 'GatorColumn' in the 'GatorTable' and
return the following records :

=======================
the jumping gator
Jump the magic alligator
the humping jumping gator
the crazy alligator jump
Them dummy alligator jumpers
.....

====

Author: Anthony Loera


Download Script:
DynamicSearch_UsingEXEC.txt


Disclaimer: We hope that the information on these script pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, or fitness for a particular purpose... Disclaimer Continued


Back to Database Journal Home



SQL Scripts & Samples Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
SQL Scripts & Samples Forum
Topic By Replies Updated
sql help!! add 1 August 22nd, 11:58 AM
How To Combine These 2 Queries into 1 Query ? tarek_land 1 June 7th, 08:37 AM
solving query svibuk 1 February 3rd, 06:08 AM
converting from a character string to uniqueidentifier saturnius 4 January 4th, 05:56 AM


















Thanks for your registration, follow us on our social networks to keep up-to-date