[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
Obviously, I am missing a lot here.
How do I "Create the function in your database then run it against your database."???
How do I do it or is it some other way to make this procedere work for another db except pubs.
Paste the create procedure code into a Query Analyser (QA)window and select the database you want to create it in from the drop down box at the top of the QA window.
Run the code - this will create the procedure in the selected database.
Then stay in QA and the same database then do
Code:
EXEC SearchAllTables 'opt'
This will find all columns that have letters opt in them. It will find opt at the beginning or at any position within the column field so it will return 'opt in' but will also find 'helicopter'.
have a look in either QA or Enterprise manager to see if the SearchAllTables exists in the stored procedure list for your database - if not you need to create it in the DB using the guide above.
its how you create the SQL statement you really want to run the ' are used to separate text from variables so you can build a string with text and variables:
'SELECT ''' + @TableName + '.' + @ColumnName
might translate in the run SQL statement to:
SELECT MYTABLE.MYColumn etc
which is what needs to be passed to the server to run the query correctly.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.