SQL Server select query output shows as "???????" - sql

I got an email from my senior, to update a table column in SQL server.
In the mail they mentioned the data to update.
But when I copied the below mentioned content and used select query in SQL Server it results in "??????" characters.
Landmark : 𝚗𝚎𝚊𝚛 𝚔𝚘𝚙𝚊𝚕 𝚔𝚒𝚍𝚜 𝚌𝚘𝚕𝚕𝚊𝚐𝚎,𝚋𝚑𝚊𝚠𝚛𝚊𝚜𝚕𝚊
select 'Landmark : 𝚗𝚎𝚊𝚛 𝚔𝚘𝚙𝚊𝚕 𝚔𝚒𝚍𝚜 𝚌𝚘𝚕𝚕𝚊𝚐𝚎,𝚋𝚑𝚊𝚠𝚛𝚊𝚜𝚕𝚊'
I tried varbinary, ASCII conversion in SQL server and tried to format the data using word and excel but nothing works for me.
To my knowledge I think the data is in image format.
Please help me with this issue.
Note: I can simply type the content and update, but for my curiosity I want to know how to fix this issue.

Related

colon(:) and dot(.) as millisecond separator in datetime2

I have migrated a Sybase database to SQL server 2008.
The main application that using the database trying to set some of dateTime2 column with data like 1986-12-24 16:56:57:81000 which is giving this error:
Conversion failed when converting date and/or time from character string.
Running the same query using dot(.) instead of colon(:) as millisecond separator like 1986-12-24 16:56:57.81000 or limiting the milliseconds to 3 digits like 1986-12-24 16:56:57:810 will solve the problem.
NOTE:
1- I don't have access to the source of application to fix this issue and there are lots of table with the same problem.
2. Application connect to database using ODBC connection.
Is there any fast forwarding solution or should i write lots of triggers on all tables to fix it using the above solutions?
Thanks in advance
AS Gordon Linoff said
A trigger on the current table is not going to help because the type
conversion happens before the trigger is called. Think of how the
trigger works: the data is available in a "protorow".
But There is a simple answer!
Using SQL Server Native Client Connection instead of basic SQL Server ODBC connection handle everything.
Note:
1. As i used SQL Server 2008 version 10 of SQL server native client works fine but not the version 11 (it's for SQL Server 2012).
2. Use Regional Settings make some other conversion problem so don't use it if you don't need it.
Select REPLACE(getdate(), ':', '.')
But it will Give String Formate to datetime Which is not covert into DateTime formate
Why would you need triggers? You can use update to change the last ':' to '.':
update t
set col = stuff(col, 20, 1, '.');
You also mistakenly describe the column as datetime2. That uses an internal date/time format. Your column is clearly a string.
EDIT:
I think I misinterpreted the question (assuming the data is already in a table). Bring the data into staging tables and do the conversion in another step.
A trigger on the current table is not going to help because the type conversion happens before the trigger is called. Think of how the trigger works: the data is available in a "protorow".
You could get a trigger to work by creating views and building a trigger on a view, but that is even worse. Perhaps the simplest solution would be:
Change the name and data type of the column so it contains a string.
Add a computed column that converts the value to datetime2.

invalid data is getting inserted in table in sql server database

I faced a situation and also searched for it in the internet but could not be able to get any solution.
Problem
My sql server table has 15000 records. It has several columns.
Among all the records, the 'Email ID' column of one record is storing value along with an unidentified character at the beginning. (Please refer to picture attached)
What I want
I want to get rid of that character using sql query. I am using sql server 2012 version.
I tried with 'replace()' and 'patindex()'. I even tried 'stuff' function.
But, its not working. Instead, when I am fetching the data using query, it is showing that typical character.
Please help me with some ideas. If I need to do some settings in database or table, I am ready for that.
Thanks.

right to left string in SQL server

Consider below query containing both Persian(a right to left language) and English(a left to right language):
SELECT 'نرم افزار SQL سرور'
the required result is this string :
سرور SQL نرم افزار
Is there any function or any other way to converting string from ltr to rtl??
It is required to add N before string literal: SELECT N'نرم افزار SQL سرور'. This is needed to correctly interpret contained Unicode characters. (Source)
Important: In some cases, please avoid using standard copy-paste in order to put SELECT into SSMS command window. This could affect the RTL/LTR order. Instead, try to open correctly composed file using File > Open.
And regarding your comment:
the result should be : سرور SQL نرم افزار`
I admit I understand RTL writing system only partially, but from what I can see, Persian words are put to the output exactly in order as you entered them (even if reading right to left). Could you show me based on Unicode Bidirectional Algorithm or similar standards document why the word order should be changed by SQL Server? Shouldn't be change you expect made by preprocessing on another place, sending expected string form SELECT N'سرور SQL نرم افزار'? I see no point why just SQL SELECT should perform the change. If it did, what would happen if you feed result of such a SELECT into another SELECT? Another transformation? I have reasons to think that SQL server is interpreting your input technically correctly.
Hint: maybe you can try to surround your RTL text by different Directional formatting characters.
Please try the same SELECT with MySQL server at SQL Fiddle. Different server and technology, but the same result as Microsoft SQL Server gave.
Result from SSMS with MS SQL Server:
Conclusion: in order to get expected result, please form the input accordingly.
Related: Transformation of word order you expected can be done by appropriate settings in user interface.
When we add digit with english this will again not work following solution will work
SELECT nchar(8234)+ N' 33-M ' + N'کلینک کمرہ نمبر' +nchar(8236) + N'میں تشریف لائیں'

Teradata Sql Assistant not showing text in the query result view

When I run a select query on an informix database using Teradata Sql Assistant all the text fields are null. But when I use another database manager like DBeaver, using a select query on the same table, I get values in the text fields. Has anyone else encountered this issue? if yes, how did you fixed it?
Thanks for the help!
I had similar issues today, try converting the text column to varchar in your select.
SELECT CAST(txt_column As VARCHAR(8000))

SQL Server 2005 select query not retrieving complete text from a column

Maybe this would be very simple, but I have no idea why this is happening.
To put in simple way, I have inserted a row into a database table which contains a ntext column called content. String value which got in to this column content has a text length of 6889 characters. However when I do a basic select query based on id, it do retrieve the row - but not the complete text from the column Content. All I see in SQL Server Management Studio for this column when I do a select query is the text with characters 43679.
There is no issue with data being inserted and I could see all the text being displayed in front end application. The issue is only when I do a select query, and copy the text to notepad, I do see fewer characters. Anything with respect to SQL Server settings/paging/statistics? Appreciate if anyone could help me out with this.
thanks,
KK
I encountered similar problem, and I found that SSMS is unable to fully retrieve column that is longer than 43680 (in output to Grid mode).
So the work around is output it as XML (unlimited length):
SELECT convert(xml,'<xml><![CDATA[' + cast([your column] as varchar(max)) + ']]></xml>')
Then do a quick search and replace (< to < , > to > ) . You can now copy the result to Notepad++ to view all the content.
SSMS returns a maximum number of characters to the grid or text window of every text based column: SSMS menu: options: Query results node : SQL node : Results to grid / Results to text
I'm sure there is a good reason for this: probably SSMS would fall over even more regularly than it does now.
Hope this helps... no such thing as a silly question