SQL Server error when i try updated a value - sql-server

My problem is this: I should update some values in my products table. The column should save a html text. So I alter my table from varchar to text type. Then I try to update the value with the content.
However, this throws an error:
string or binary date must be truncated
What could be the problem because the length property does not the problem?
Thanks in advance.

Related

Edit Rows grid: string or binary data would be truncated

I am trying to change a "Y" to an "N" in a column. I have already changed that value in several rows, but one specific row is throwing the error.
Here is the error:
The data in row 170 was not committed.
Error Source: .Net SqlClient Data Provider.
Error Statement: String or binary data would be truncated.
The statement has been terminated.
What is it about this row that is causing this error?
Changing a 'Y' to an 'N' shouldn't cause a problem.
Check the Table for a Trigger that might be sending data to another Table where the Truncate is occurring on another Field.
One solution would be to use a query to update the value instead of (I'm guessing) the edit rows designer in SSMS.
e.g. If your table was tbl, the column was col, and your primary key was id and that value was 170.
update tbl set col='N' where id = 170;

Cannot find either column “dbo” or the user-defined function or aggregate “dbo.ToTitleCase”, or the name ... when editing cell value

When I try to edit a field value in my table (using SSMS) I get the above error.
I get the same error when trying to run an update query like this:
update Users
set fieldvalue = 'aaa'
where ID = 123
I looked at the Column Properties to see if there is any Compute field specification but could find any.
How this function is linked to this field?
Where is it coming from?
The error message occurred because of trigger on the table.
enter image description here

MSSQL + Laravel: "Error by converting varchar to bigint"

Actually, I can't insert data into a table with big number.
The primary key has type of BIGINT, when I try to insert a row I'm getting this error.
Same thing happens when I try it manually with HeidiSQL.
It seems you are going to insert string/varchar/nvarchar data to your BIGINT type column. please check your data.
The problem is solved. It's been caused by a trigger in the database, which tried to put a string with "8001049473-A1-R" into a bigint field. After deleting that row containing the "8001049473-A1-R", everything works.

Date Conversion Issue MS Access to SQL Server

I'm creating a table B from an exisitng table A. In the table A I have a column ValDate which is varchar and contains Date. When I try to create the table B I have a function used in the query as given below and I get a conversion error. Table A contains null values as well.
MS Access:
((DateDiff("d",Date(),format(Replace(Replace([Table A].ValDate,".","/"),"00/00/0000","00:00:00"),"dd/mm/yyyy")))>0)).
Tables were in MS Access and are being migrated to SQL Server 2012.
SQL Server:
((DATEDIFF(day,FORMAT( GETDATE(), 'dd-MM-yyyy', 'en-US' ),FORMAT( ValDate, 'dd-MM-yyyy', 'en-US' ))>0))
or
((DateDiff(day,GETDATE(),Format(Replace(Replace([TableA].[ValidFrom],'.','/'),'00/00/0000','00:00:00'),'dd/mm/yyyy')))
I tried converting the date using several approachs like Convert , Format and Cast but I end up getting error as below.
Msg 8116, Level 16, State 1, Line 1
Argument data type date is invalid for argument 1 of isdate function.
I would really appreciate someone telling me what I'm missing here.
since you have date data in a string field is very likely you have some value that is not valid against your expected date format.
copy the data in a sql server table and then perform check and validation of the content of the string field.
have a look to the function try_convert that can be helpful when checking the content of the string field containing the date values.
when bad data is ruled out you can apply again your formula with (hopefully) a different result.
a better solution would be to create a separate field with appropriate datatype to store date values converted from the string field and apply your logic to that field.

Storing native language strings in SQL columns with user defined datatypes

My Table name is property_pair_master. And one of the column in it is
prop_value (its datatype is varchar(max));
I created my userdefined datatype using the below query
EXEC sp_addtype 'tinyUTF8','varbinary(8000)','NULL'
Now I changed the datatype to my tinyUTF8 (my defined datatype).
Problem is when I am trying to update the value in it using the below query
update property_pair_master set prop_value =
CONVERT('મારું માહિતી પરીક્ષણ' AS tinyUTF8) where id=1
getting the error message as
Incorrect syntax near 'મારું માહિતી પરીક્ષણ'.
How can I update the String into Database?
Is there any alternative to do this. Any suggestions ?
Note : I am using SQL SERVER 2008.
Thanks in advance.
HHHahh...
I found the solution and got rid off cast and convert
Updated the datatype to nvarchar(MAX) .And I updated my query as
update property_pair_master set prop_value = N'વ્યાવહારિક' where id=1

Resources