This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes sql server question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "sql server question" Watch "sql server question" New topic

sql server question

Brian Percival
Ranch Hand

Joined: Jun 23, 2004
Posts: 163
I am kinda new to tsql programming and trying to find a quickie from google and such for a solution.

What I want is to get a list of tables and columns that contain a certain string. I actually want to replace all such occuranaces with some other string but here is how I started:

When I try to run ths, it complains that table variable @tn is not declared. Obviously I cann't use a varchar variable in place of a table, looks like..

Can anyone point out how I should change the above? I basically want to use the @tn and @cn as table name and column name in my 'select' inside the loop. HOW???

Thanks for your time.
Brian Percival
Ranch Hand

Joined: Jun 23, 2004
Posts: 163
I got this from forums

Hope this helps posterity.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31571

Thanks for posting the solution Brian!

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: sql server question