Replace a single character in a textual column in sql server
Hello,
could you confirm to me that:
UPDATE TableName
SET LastName = REPLACE(LTRIM(RTRIM(LastName)), 'A', 'B')
replaces every occurrence of character A with character B, in selected column, regardless
of the position of the letter A? (I.E., it could be only at the beginning of the last name, at the both i.e., at the beginning and somewhere in a middle etc....just any occurrence of it?)
select REPLACE(LTRIM(RTRIM(lastname)), 'A', 'B') from tablename
Yes, It will update all occurence of character 'A' of lastname.
You can also execute the select statement for cross verfication
-Prashanth
Similar Messages
-
How do I find & replace a single character?
Am using Adobe Acrobat Pro....
The find/replace box pull down has "Whole Words Only" checked and I cannot uncheck it. How can I find and replace a single character throughout a document?That's just how it works. You can "find" anything, but you can only "replace" whole words. As soon as you click to open the "replace" section of the dialog the search settings are locked into their basic states, even if you don't enter a replacement string (but that part's a bug).
The simple answer is that you cannot replace all instances of one character using Acrobat's inbuilt tools. You're expected to edit the document outside of PDF and recreate it. -
How to convert rows to columns in sql server 2008
How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)
Lookup the Pivot transformation. From BOL:
The Pivot transformation makes a normalized data set into a less normalized
but more compact version by pivoting the input data on a column value. For
example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
null values.
When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
The column is passed through unchanged to the output. Because many input rows
can result only in one output row, the transformation copies only the first
input value for the column.
The column acts as the key or part of the key that identifies a set of
records.
The column defines the pivot. The values in this column are associated with
columns in the pivoted dataset.
The column contains values that are placed in the columns that the pivot
creates.
Paul -
Desc doesn't show datetime columns from SQl Server
Hi Everyone,
I have working db link to sql server using hsodbc:
Oracle 10.2 on AIX using freetds odbc driver version 0.82.
I can access tables on sql server but oracle sees only varchars and numerics columns in a table.
Is there a way to select datetime columns from sql server using hsodbc?when hsodbc does not show a certain data type it is commonly related to the fact that HSODBC doesn't support the related ODBC data type.
In general you have a data type in your SQL Server which is mapped to an ODBC data type by the ODBC driver. HSODBC then maps the ODBC data type to an Oracle equivalent and when the ODBC data type isn't supported by HSODBC it just drops it from the select list.
So for a root cause analysis an ODBC trace is required to determine the mapping of the FreeTDS ODBC driver.
With this info we can then compare the mapping documented in the HSODBC manual and if the ODBC data type isn't listed as a supported data type you then need to cast the data type on the source side to a different data type (for example varchar/char).
So please post the ODBC trace and I'll have a look.
- Klaus
Edited by: kgronau on Apr 2, 2013 12:50 PM
BTW, here the link to the HSODBC docu:
http://docs.oracle.com/cd/B19306_01/server.102/b14232.pdf
Oracle® Database
Heterogeneous Connectivity Administrator's Guide
10g Release 2 (10.2)
B14232-01
B.1 Mapping ANSI Data Types to Oracle Data Types Through an ODBC
Interface -
What is Oracle's alternative to IDENTITY Column in SQL Server/ DB2
What is Oracle's alternative to IDENTITY Column(Auto Increment Column) in SQL Server/ DB2 ? Is Sequence and Trigger the only way out for this?
Why is Oracle not creating anything like an Identitiy column in SQL Server?What is Oracle's alternative to IDENTITY Column(Auto
Increment Column) in SQL Server/ DB2 ? Is Sequence
and Trigger the only way out for this?Of course not, you can use in your inserts sequences as well:
insert into blahh values (my_seq.nextval, ...) and use returniong clause to get the value back if necessary
You can use them in insert with subselects
insert into blah
select my_seq.nextval, ...
from ....
>
Why is Oracle not creating anything like an Identitiy
column in SQL Server?Because they are different companies with different people and thoughts and existing mechanism is sufficient i.e. one can even argue that it is even more flexible than identity btw ;)
Gints Plivna
http://www.gplivna.eu -
How to Encrypt Column in SQL Server?
Hi all,
I am using ColdFusion MX 7 and Microsoft SQL Server 2000
database. I have a column that contains social security numbers of
my users and am feeling the need to encrypt that column.
Trouble is, I have no clue how to do this in SQL Server or
how I could display the data from that column in my web app once
the column is encrypted.
Can anyone offer any suggestions?
Thanks in advance!Here's one way...
To encrypt:
URLEncodedFormat(Encrypt(yourSStoencrypt,
application.encKey)) then
store this value in MSSQL
To decrypt:
Decrypt(URLDecode(yourSStodecryptfromDB), application.encKey)
HTH
Tim Carley
www.recfusion.com
[email protected] -
Hi all,
I am having below table.
create table Student_Register
Name varchar(30),
FatherName varchar(35),
Address1 varchar(100),
Address2 varchar(100),
Place varchar(75),
Pincode int,
SchoolName varchar(100),
StandardStudy varchar(15)
I am creating after trigger on the above table and inserting into the below table.
create table StudentDetails
Name varchar(30),
FatherName varchar(35),
Address1 varchar(100),
Address2 varchar(100),
Place varchar(75),
Pincode int,
SchoolName varchar(100),
StandardStudy varchar(15)
I need to create one computed column in studentdetails as StudentID with StandardStudy+Replicate(0,3)+lastvalue+1
5th student id
50001
50002
12th student like
120001
120002
120003
how to implement above logic pls ?
Thanks
Selvaons
Thanks - SelvaKumarSubramaniam.Please MARK AS ANSWER, if my answer is useful to U.see
http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server
You can make it computed column based on UDF
make UDF as below
CREATE FUNCTION GenerateStudID
@StdStudy varchar(15)
RETURNS int
AS
BEGIN
DECLARE @StudID int
SELECT @StudID = @StdStudy * 10000 + COALESCE((SELECT MAX(StudentID) FROM StudentDetails WHERE StandardStudy =@StdStudy),0) + 1
RETURN (@StudID)
END
then create column as
ALTER TABLE StudentDetails ADD StudentID AS dbo.GenerateStudID(StandardStudy)
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Accessing IMAGE Columns in SQL Server
I'm trying to use the TG4MSSQL to access tables in a SS2k database. All is well, except for 1 table that has an IMAGE column in it. I must say that I'm a little surprised and disappointed that the 10gR2 gateway for MSSQL apparently translates these things into LONG RAW columns, which are known to be antiquated and minimally supported. However, I still need access to the data, and ultimately, I need it in a BLOB. Doing simple queries (in TOAD) such as:
select * from image@tg4ss where image_id = 1;
returns the row, and I can use TOAD to determine that all the data is there. However, apparently, you cannot use PL/SQL to bind more than 32K of this data into a variable, so I haven't had much success there.
The only way I know of converting a long raw to a blob is to use the to_lob function, but that's only good in the select list of a subquery of an insert statement. Thing is, that doesn't seem to work with the gateway. I tried something like:
insert into my_blob_table( id, image )
select id, to_lob(image) as image from image@tg4ss where id = 1;
That gets me a ORA-00997: illegal use of LONG datatype.
In fact, I can't even do this:
insert into my_long_raw_table( id, image )
select id, image from image@tg4ss where id = 1;
I get the same error on that command.
Now, I can do this, but I only get the first 32k of the image:
begin
for I in (select id, image from IMAGE@tg4ss)
loop
insert into my_long_raw_table( id, image )
values (I.id, I.image);
end loop;
end;
So, does anyone know how you can get image data out of an SQL Server database into a blob value? If so, I'd appreciate a reply. Thanks.
-Rich.Hello Rich,
I found your article after running into the same problem. I imagine you've dealt with this one way or another already but just in case...
The reason the LONG RAW gets truncated is explained in:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/datatypes.htm#i43252
Basically, LONG RAW variables are limited to 32760 bytes inside PL/SQL. The ORA-00997 error is explained a little in:
http://www.dbaxchange.com/3_4_longdatatypes.htm
The only solution I found to work was to create a Java utility that read in each LONG RAW value (one at a time) and then update a record in a table's BLOB column. This was even a bit tricky. I found the gateway would lock up if I tried to do too much at a time. I kept it simple my reading all column IDs into an array and then looping through the array while executing a simple select statement that retrieved the LONG RAW value. I concatenated the id to the end of the select statement because prepared statements seemed to be one of the reasons the gateway locked up. I used a ByteArrayInputStream object to populate the BLOB in an update prepared statement for each LONG RAW value processed in the loop.
- Aaron -
How to export an image column from SQL server to an excel
Hi team,
Would like to know how can i get an Image column storeed in SQL Server database to get copied in Excel (Hard Drive).
Requirement : Need to get Username, User email address and User photo in to an excel sheet from SQL server database.
Fix: I can get Username and Useremail adress however could not find a way to export /Copy user Image.
Please suggest
Thanks,
venkateshThis is an Oracle forum. Your question relates to SQL Server and Excel, neither of which are Oracle related.
-
How can I export image column from SQL Server 2000
Hi everybody,could someone tell me how can I export an entire column( pictures type) to a folder on disk?I've tried the textcopy.exe under the SQL installation's binn folder,it can only export one picture a time,I'm trying to find an automated way to export
the whole colum's images to a folder,I'm using SQL Server 2000.Vishal,thanks for the replay,I've tried the BCP method but it seems does not work on my Sql Server 2000,also the SSIS package method is demonstrated with Sql Server 2008 R2 and my machine does not have the visual application to try it.In the BCP method,I
got prompt indicating me that I wrote something wrong in the grammer,and I'm pretty sure that maybe I made something wrong in the below part,the grammer makes me confused
INSERT
INTO @sqlStatements
SELECT 'BCP "SELECT Photograph_Data FROM [ALBSCH_Trial].[dbo].[Photograph] WHERE Photograph_ID = '''
+ CAST(Photograph_ID AS VARCHAR(500)) + '''" queryout ' + @OutputFilePath
+ CAST(Photograph_ID AS VARCHAR(500)) + '.jpg -S localhost\SQLEXPRESS2008 -T -f C:\SQLTest\Images.fmt'
FROM dbo.Photograph -
How mapping sharepoint list Columns to Sql server data table columns programaticlly
Hi ,
I have one Verification List in share Point ,in that list i have 10 columns.And we have sql server in that sql server we have one data table Verification_Table
in that table we have 25 column, my requirement is all list data move to sql data table[ what ever columns mapping to list--->data table that data store in data table reaming column is Null]
using grammatically not in BCSHello,
You can create SQL connection and use Datareader to read from SQL.Firs create a connection string and put this string in web application web.config file of your sharepoint site.
Now use below code to call your connectionstring in your webpart.
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
Here is link to read the data from SQL:
http://www.akadia.com/services/dotnet_data_reader.html
Here is one MSDN link to read SP list data:
http://msdn.microsoft.com/en-us/library/dd490727%28v=office.12%29.aspx
Let me know if you have any doubt
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Nvarchar column filter - SQL server
Hello,
I am using OBIEE 10.1.3.4.2 and I have problem with filtering data coming from SQL server 2008. I am using ODBC connection to access SQL server data. I can see results of my queries without any problem.
But I have problem with filtering.
My answer use these columns:
Id (varchar(36))
Code (nvarchar(256))
Name (nvarchar(256))
HappenedOn (date)
Please look on this screenshost:
http://img59.imageshack.us/img59/5242/obieenvarcharcolumn.jpg
Screenshot
I have problem when I want to use filter on Code column and use some non-english characters. Specifically Czech characters in windows1250 code page. With that filter I am getting "No result" view. But generated select is working in Microsoft SQL Server Management Studio.
I think there is some problem with ODBC resource or BI configuration, but I can not find reason of this behaviour.
Do I need to make some specific configuration to use NVARCHAR columns? Specifiy some encoding etc....
Thank youThank you Dpka...
Checking UNICODE option on Write Back tab solved my problem. It is realy nice hidden property :-)
But my fight is not over...
Now I am getting error when I try to make join between table from Oracle and table from SQL server.
It is a Bug ID 9147807 and I hope that Patch (9147807: INCORRECT SYNTAX NEAR 'SESSION' WHEN QUERYING FRAGMENTED LOGICAL FACT TABLE) will help me. -
Single jdbc connection opens multiple connections to sql server
Hello!
I'm having a bad problem, because one jdbc connection opens multiple connections to the sql server. I'm working with the open source jdbc driver jtds and the ms sql server. Because I'm using temporary tables that are only visible to one database connection, my code doesn't work. Is this a bug in jtds or is this the normal behaviour of a java.sql.Connection?
Here a code example:
Class.forName("net.sourceforge.jtds.jdbc.Driver");
conn = DriverManager.getConnection(
"jdbc:jtds:sqlserver://"+dbConnDef.getServer()+"/"+dbConnDef.getDatabase(),
dbConnDef.getUserName(),
dbConnDef.getUserPasswd()
Statement stmt = conn.createStatement();
stmt.executeUpdate("SET DATEFORMAT YMD");
stmt.close();
stmt = conn.createStatement();
stmt.executeUpdate("CREATE TABLE #tmp (FieldA INT NOT NULL)");
stmt.close();
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM #tmp");
stmt = conn.createStatement("SELECT FieldA AS sthElse FROM #tmp");
ResultSet rs2 = stmt.executeQuery("SELECT * FROM #tmp");
// the strange thing is, that this second query does NOT yet open a
// new connection, but the next sql command does.
stmt = conn.createStatement();
stmt.executeUpdate("DROP TABLE #tmp");
stmt.close();
Why is it behaving that strange way? It is absolutely necessary, that EVERYTHING that I do with my connection is really done on the same connection to the SQL server! How can I force a java.sql.Connection not to open multiple sql-server-connections?
It is very urgent, thus, PLEASE HELP!!!
Thousand thanks in advance! Marco....but that means, that the jdbc driver I use, is not working properly, because it should work the following way (please correct me, if I misunderstood the concept):
I create a Connection object which should represent exactly one physical connection to the database. Then I can create as many Statement instances by conn.createStatement() as I want. There should still exist only one physical connection.
With each of my Statement objects, I can create one result set.
This means, I should be able to create as many result sets as I want to with only one Connection object (and therefor one physical connection) by creating multiple Statements, right?!
If this is correct, the concept is perfect for me and exactly as I'm used to it by other programming languages. Then, only my jdbc driver does not work properly which means I either have to replace it by another one or change it myself (it's open source). -
How to replace a character at a random position of a column in SQL Server 2000?
Hello everyone,
I'm trying to export the data of a table into a flat file. However, when I try to export it, a column which has a specific character (".") is being loaded as a new column into the file rather than the same column.
Here is the DDL/DML:
CREATE TABLE [dbo].[EXT_Name](
[A_Name] [VARCHAR](4),
[U_Name] [VARCHAR](256),
[U_Desc] [VARCHAR](256),
[Acc_Desc] [VARCHAR](256),
[S_Type] [VARCHAR](50))
Its just that's it. No more Keys and Indexes on this table.
Here is the bcp command I'm running:
EXEC [master].[dbo].[xp_cmdshell] 'bcp "SELECT * FROM [dbo].[Ext_Name]" queryout C:\Data\Ext_Name.dat -c -t, -T -S'
Data:
GEHG,/User/Personal/Project/Click.do,Search for User Project.,See Summary,Summaries
GEHG,/User/Personal/Project/Click.do,Search for User Project.Detail,null,Summaries
Instead for the data to be loaded as the above, its loading into the file as
GEHG,/User/Personal/Project/Click.do,Search for User Project.,See Summary,Summaries
GEHG,/User/Personal/Project/Click.do,Search for User Project.Detail
,null,Summaries
This issue occurs only when [Acc_Desc] column has the "." character in between the string. Could experts in this forum help me please?
Thank you,
Bangaaram
Known is a DROP, Unknown is an OCEAN.That is most likely not your problem. Your problem is most likely the source data has a CR and/or LF after it in the database.
Run this to remove them from Acc_Desc:
UPDATE [dbo].[EXT_Name]
SET [Acc_Desc] = REPLACE(REPLACE([Acc_Desc],CHAR(13),''),CHAR(10),'')
Perfect! Thank you Tom :)
Known is a DROP, Unknown is an OCEAN. -
Replace a single character with Regular Expressions
Hello,
I would like to replace a character by a string.
For example, "12<15" ---> "12&#xx;15"
To that aim, I use the following code:
String s = "12<15";
s.replaceAll("<", "&#xx;");Unfortunately, it doesn't work. The string is not altered.
What's the bug?
Thanks for your help.try
s = s.replaceAll(.....)
Rgds
Maybe you are looking for
-
Where is the Command Wizard in BEx Web Application Designer(WAD) 7.0
Hi, I am new to SAP and BEx Web App Designer and am reading through the help about the so-called Command Wizard. I have looked all over the app and I see nothing called a Command Wizard. I am I missing something obvious or is this buried somewhere in
-
No interface Idoc in Business system Receiver
Hello, I have one question concerning my interface for receiver. My scenarion is File to Idoc and when I configure my receiver determination, and I choose my business system receiver 'BS_ER6CLNT001' I don't find my interface 'CREMAS.CREMAS05' insinde
-
JBuilder Question - Where do i put the code?
I am building a jList using the designer in Jbuilder. In what event procedure do i put the code that assigns an array and so on? thanks for any help maggie evans
-
Any URLs to download PreInstalled Fresh Copy of Oracle Applications R12
Hi Gurus I am looking for fresh copy of Oracle Applications R12, if any one has this copy, can you please share it. If there is a installation of Oracle Apps R12 on Microsoft Virtual Machine, it can be easily shared and kept as backup copy. It will b
-
I am using Encore CS4. Under Edit>Preferences>Media, there is a button to clear the cache files. But, doing this does not clear the cache (c:\Documents and Settings\James\Application Data\Adobe\Common\Media Cache and Media Cache Files). I am the only