This question already has answers here:
SQL Server - Remove all non-printable ASCII characters
(4 answers)
Closed 4 years ago.
I have a sql server table where control characters appear when column is copied and pasted into notepad. I need to remove/replace these control characters. For example here is a text i copied from my sql server table into notepad
How do i remove "OSC". I have searched the net and here but cant find anything on this. Table was imported from SSIS as ANSI (i also tried data conversion in ssis to convert the column to ascii but still to no avail).
"OSC" is CHAR(157). Try using REPLACE(Values, CHAR(157), ''). If it works then you can update in the table. Hope it helps.
Related
This question already has answers here:
What is the meaning of the prefix N in T-SQL statements and when should I use it?
(4 answers)
Why is sql server storing question mark characters instead of Japanese characters in NVarchar fields?
(8 answers)
Closed 4 months ago.
I have a text in the database with the symbol "➜". When I display it on the web page, I get a "?" instead. Can someone help me?
Best regards
This question already has answers here:
Empty space at the end of SQL Server query results
(3 answers)
Closed 8 months ago.
I'm currently working in an SQL database where a column has trailing spaces.
The spaces in question show up as %20 in the browser url.
I've been able to remove them with a select query but whenever I convert it to an update an set query it doesn't seem to work, any input would be appreciated.
Working select query:
select [dbo].[udf-Str-Strip-Control](identifier)
from [AHDRC].[dbo].[artworks]
Broken update query:
update [AHDRC].[dbo].[artworks]
SET [identifier] = [dbo].[udf-Str-Strip-Control](identifier);
SELECT [identifier]
From [AHDRC].[dbo].[artworks];
I am currently using SQL server management studio
[identifier] is a nchar(128)
Apologies if anything is unclear / badly formatted.
[identifier] was a nchar(128) causing trailing spaces.
This question already has answers here:
How do I search for names with apostrophe in SQL Server?
(9 answers)
Closed 5 years ago.
If im trying to search for 'RYAN'S TEAM' in sql it doesnt like the fact that i have an apostrophe ' in RYAN'S and detects that as the end of the LIKE statement.
[Team] LIKE '%RYAN'S TEAM%'
It recognises the whole next line as red in sql server. Is there anyway around this as RYAN'S TEAM is the way it is stored in the database.
This will work:
[Team] LIKE '%RYAN''S TEAM%'
You just have to double the quote chars.
This question already has answers here:
How can I comment special \ commands in PostgreSQL's psql commandline tool?
(5 answers)
Closed 8 years ago.
I have a query in an excel file that I inherited from the previous user/creator of the tool. The external connection is to a PostgreSQL database. Here's the line of script that I need to decipher so that I can hopefully adjust the date range for the query:
with
icon_date as (select max(icon.date::date)/* '1/1/2014'::date*/ as icon_date from pmm.icon)
...
pmm is the schema and .icon is the table name
My specific question is what this part means:
/* '1/1/2014'::date*/
I have no clue what surrounding a date::data type with /* */ would do in the first part of the query. Any ideas? I can post more of query if that would help.
That is just a comment and it will be ignored.
There are (at least) two ways to put comments into SQL:
everything after -- until end of line
everything between /* and */ (even spanning lines)
My guess is that this is code left over from testing, where instead of the max you would select some fixed date (because it is faster, or data was missing).
This question already has answers here:
CSV import in SQL Server 2008
(3 answers)
Closed 8 years ago.
I am using BULK INSERT to import a text file into a table.
The data imports OK but is quoted. for example
"1235","Bob Dylan","Dylan","Bob"
I have read a bit on this and have I created a format file using BCP that resolves the problem except the leading quote. ie:
"1235,Bob Dylan,Dylan,Bob
How can I remove the leading quote
In the past I have used an XML format file with a dummy row of 1 character length. Maybe someone else has a more elegant solution but that worked for me.