Hi,
The following script does not return any resultset against a test db
while I know for a fact tables with letter "aaa" has columns that
contains "ccc".
What's wrong? the the inner cursor?
Thanks.
-- get all tbls with letter aaa
declare @tbl varchar(8000)
declare tblCursor cursor for
SELECT name
FROM sysobjects
WHERE xtype = 'U'
AND name LIKE '%aaa%'
open tblCursor
fetch next from tblCursor
into @tbl
while (@@fetch_status = 0)
begin
-- get all columns with letter ccc and replace it with nothing /
remove it
declare @tbuffer varchar(4000)
declare @cbuffer varchar(8000)
declare abnormal_cols cursor for
SELECT o.name, c.name
FROM sysobjects o
JOIN syscolumns c ON o.id = c.id
WHERE o.xtype = 'U'
AND c.name LIKE '%ccc%'
and o.id = object_id('+@tb l')
-- ORDER BY c.name
open abnormal_cols
fetch next from abnormal_cols
into @tbuffer,@cbuff er
while (@@fetch_status = 0)
begin
-- EXEC sp_rename '+@tbuffer+'.['+@cbuffer+']','+Replace(+@c buffer+','%ccc% ','')',
'COLUMN';
-- test
print @tbuffer + ', ' + @cbuffer;
fetch next from abnormal_cols
into @tbuffer,@cbuff er
end
close abnormal_cols
deallocate abnormal_cols;
fetch next from tblCursor
into @tbl
end
close tblCursor
deallocate tblCursor; 1 1715
Hi
I can't see why there are two cursors here, try:
SELECT o.name, Replace(c.name, 'ccc','') as NewName, c.name as OldName
FROM sysobjects o JOIN syscolumns c ON o.id = c.id
JOIN syscolumns a ON o.id = a.id
WHERE o.xtype = 'U'
AND c.name LIKE '%ccc%'
AND a.name LIKE '%aaa%'
John
"Doug Baroter" <qw********@box frog.com> wrote in message
news:fc******** *************** ***@posting.goo gle.com... Hi,
The following script does not return any resultset against a test db while I know for a fact tables with letter "aaa" has columns that contains "ccc". What's wrong? the the inner cursor?
Thanks.
-- get all tbls with letter aaa declare @tbl varchar(8000) declare tblCursor cursor for SELECT name FROM sysobjects WHERE xtype = 'U' AND name LIKE '%aaa%'
open tblCursor fetch next from tblCursor into @tbl
while (@@fetch_status = 0) begin
-- get all columns with letter ccc and replace it with nothing / remove it declare @tbuffer varchar(4000) declare @cbuffer varchar(8000)
declare abnormal_cols cursor for SELECT o.name, c.name FROM sysobjects o JOIN syscolumns c ON o.id = c.id WHERE o.xtype = 'U' AND c.name LIKE '%ccc%' and o.id = object_id('+@tb l') -- ORDER BY c.name
open abnormal_cols fetch next from abnormal_cols into @tbuffer,@cbuff er
while (@@fetch_status = 0) begin -- EXEC sp_rename
'+@tbuffer+'.['+@cbuffer+']','+Replace(+@c buffer+','%ccc% ','')', 'COLUMN'; -- test print @tbuffer + ', ' + @cbuffer; fetch next from abnormal_cols into @tbuffer,@cbuff er end
close abnormal_cols deallocate abnormal_cols;
fetch next from tblCursor into @tbl
end close tblCursor deallocate tblCursor; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jamesfin |
last post by:
Dear XMLers,
Please guide me...
I have a simple xml file...
<URLTest>
|
by: Eric |
last post by:
I have a custom component that can be dragged from the ToolBox onto a
Windows Form (which means I can't modify it's constructor to add a name
parameter). VS assigns it an instance name, but the developer can
modify it's name. The name shows up in the property window as "(name)",
I want to find a way to access that name programatically, so that
instance of the control wil be able to determine it's own name. I have
the source for the control...
|
by: James Fifth |
last post by:
Hello and God Bless,
I am stumped trying to get a simple xml database replacing certain data
with other data programmatically. This is what my xml looks like.
****************************************
<Root_Element>
<Topic index="1">
<Sub_Topic>
<Notes></Notes>
|
by: David |
last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll
get an answer, so trying here.
I'm trying to convert a script to use friendly URLs, I've done this
before, but my PHP skills are quite basic so far, far from proficient
at this.
..htaccess file-
DirectoryIndex default.php index.asp index.html index.htm index.php
|
by: Tom Plunket |
last post by:
I've got a bunch of code that runs under a bunch of unit tests. It'd
be really handy if when testing I could supply replacement
functionality to verify that the right things get called without those
things actually getting called, since frequently those calls take a
long time to execute and do things that, well, I don't really want to
do.
E.g. imagine you've got a routine which takes a filespec, generates a
list of files, and copies...
| |
by: patelgaurav85 |
last post by:
Hi,
I want to convert xml in one format into another xml format shown below
Input xml :
<Name>
<Name1>
<Name11>Name11</Name11>
<Name12>Name12</Name12>
|
by: kj7ny |
last post by:
Is there a way that I can programmatically find the name of a method I
have created from within that method? I would like to be able to log
a message from within that method (def) and I would like to include
the name of the method from which it was written without having to
hard-code that value in every message string. While we're at it, is
there a way to programmatically get the name of the class and the
module while I'm at it?
...
|
by: Jan Erik Hansen |
last post by:
I have a function with a dynamic sql block like this (fieldname and
fieldvalue are input parametrs to the function) :
strSQL = "UPDATE myTable SET " + fieldname + "=" + fieldvalue +
"' where myID = " + knr
I have to determine whether fieldname is a string or numeric to get the
correct
SQL syntax.
|
by: kimkamp |
last post by:
I want to create a variable name programmatically.
For instance:
Dim GlobVar as String = "My.STL."
Dim VarName as String = "sAccountNo"
Dim VarValue as String = "ABC123"
I want to end up with the following line of code, assigning a variable a value:
My.STL.sAccountNo = "ABC123"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |