Wednesday, March 28, 2012
Remove Character from a table?
Some of these entries have $ in them.
I don't want to manually go through all of these and remove the $, so I'm
wondering if there's an easy way to do this with a script or something?
Thanks,
Terry"Terry Matthews" wrote:
>I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
> Thanks,
> Terry
I believe you want to update using the REPLACE function...
UPDATE SomeTable
SET SomeField = REPLACE(SomeField, '$', '')
WHERE SomeField LIKE '%$%'
Craig|||Terry Matthews (nospam@.hotmail.com) writes:
> I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
UPDATE tbl
SET col = replace(col, '$', '')
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Great thanks, worked perfectly.
Just put in the column name instead of "somefield"
Thanks
Terry
"Craig Kelly" <cnkelly@.spamnomore.worldnet.att.net> wrote in message
news:gJS9f.11244$qk4.5037@.bgtnsc05-news.ops.worldnet.att.net...
> "Terry Matthews" wrote:
>
> I believe you want to update using the REPLACE function...
> UPDATE SomeTable
> SET SomeField = REPLACE(SomeField, '$', '')
> WHERE SomeField LIKE '%$%'
> Craig
>
Remove Character from a table?
Some of these entries have $ in them.
I don't want to manually go through all of these and remove the $, so I'm
wondering if there's an easy way to do this with a script or something?
Thanks,
Terry
"Terry Matthews" wrote:
>I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
> Thanks,
> Terry
I believe you want to update using the REPLACE function...
UPDATE SomeTable
SET SomeField = REPLACE(SomeField, '$', '')
WHERE SomeField LIKE '%$%'
Craig
|||Terry Matthews (nospam@.hotmail.com) writes:
> I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
UPDATE tbl
SET col = replace(col, '$', '')
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||Great thanks, worked perfectly.
Just put in the column name instead of "somefield"
Thanks
Terry
"Craig Kelly" <cnkelly@.spamnomore.worldnet.att.net> wrote in message
news:gJS9f.11244$qk4.5037@.bgtnsc05-news.ops.worldnet.att.net...
> "Terry Matthews" wrote:
>
> I believe you want to update using the REPLACE function...
> UPDATE SomeTable
> SET SomeField = REPLACE(SomeField, '$', '')
> WHERE SomeField LIKE '%$%'
> Craig
>
Remove Character from a table?
Some of these entries have $ in them.
I don't want to manually go through all of these and remove the $, so I'm
wondering if there's an easy way to do this with a script or something?
Thanks,
Terry"Terry Matthews" wrote:
>I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
> Thanks,
> Terry
I believe you want to update using the REPLACE function...
UPDATE SomeTable
SET SomeField = REPLACE(SomeField, '$', '')
WHERE SomeField LIKE '%$%'
Craig|||Terry Matthews (nospam@.hotmail.com) writes:
> I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
UPDATE tbl
SET col = replace(col, '$', '')
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Great thanks, worked perfectly.
Just put in the column name instead of "somefield"
Thanks
Terry
"Craig Kelly" <cnkelly@.spamnomore.worldnet.att.net> wrote in message
news:gJS9f.11244$qk4.5037@.bgtnsc05-news.ops.worldnet.att.net...
> "Terry Matthews" wrote:
>
> I believe you want to update using the REPLACE function...
> UPDATE SomeTable
> SET SomeField = REPLACE(SomeField, '$', '')
> WHERE SomeField LIKE '%$%'
> Craig
>sql
Remove Character from a table?
Some of these entries have $ in them.
I don't want to manually go through all of these and remove the $, so I'm
wondering if there's an easy way to do this with a script or something?
Thanks,
Terry"Terry Matthews" wrote:
>I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
> Thanks,
> Terry
I believe you want to update using the REPLACE function...
UPDATE SomeTable
SET SomeField = REPLACE(SomeField, '$', '')
WHERE SomeField LIKE '%$%'
Craig|||Terry Matthews (nospam@.hotmail.com) writes:
> I have a table that has several entries.
> Some of these entries have $ in them.
> I don't want to manually go through all of these and remove the $, so I'm
> wondering if there's an easy way to do this with a script or something?
UPDATE tbl
SET col = replace(col, '$', '')
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp|||Great thanks, worked perfectly.
Just put in the column name instead of "somefield"
Thanks
Terry
"Craig Kelly" <cnkelly@.spamnomore.worldnet.att.net> wrote in message
news:gJS9f.11244$qk4.5037@.bgtnsc05-news.ops.worldnet.att.net...
> "Terry Matthews" wrote:
>>I have a table that has several entries.
>> Some of these entries have $ in them.
>> I don't want to manually go through all of these and remove the $, so I'm
>> wondering if there's an easy way to do this with a script or something?
>> Thanks,
>> Terry
> I believe you want to update using the REPLACE function...
> UPDATE SomeTable
> SET SomeField = REPLACE(SomeField, '$', '')
> WHERE SomeField LIKE '%$%'
> Craig
>
Wednesday, March 21, 2012
Remote Stored Procedure exec from variable
I have a server that is linked to several other servers. I have been able to successfully execute a procedure manually to each from the common server by executing this:
exec server1.dbname.owner.procedure
go
exec server2.dbname.owner.procedure
go
exec server3.dbname.owner.procedure
go
While this is ok, I'd like to wrap this in a loop to execute the procedure but switch out the server name in each iteration (something like this):
while @.variable is not null
begin
select @.server = 'change name in loop'
select @.str = @.server+'.dbname.owner.procedure'
exec @.str
end
This unfortunately does not work. The execute is acting like the server portion of the name does not exist (defaulting to local). I have attempted to use the AT SERVERNAME syntax in a similar fashion and been unsuccessful.
Is there some way I could dynamically create the four part name and execute it?
Any assistance would be greatly appreciated.
Thanks, Mark
DECLARE @.server nvarchar(128)
DECLARE @.cmd nvarchar(1000)
SET @.server = 'MyServer'
SET @.cmd = 'EXEC ' + @.server + '.MyDatabase.MySchema.MySproc'
EXEC (@.cmd)