I have a table (name: errors) with lots of rows. some of rows of this table shows in following:
202 16 Invalid type '%s' for WAITFOR. Supported data types are CHAR/VARCHAR, NCHAR/NVARCHAR, and DATETIME. WAITFOR DELAY supports the INT and SMALLINT data types.
203 16 The name '%.*ls' is not a valid identifier.
204 20 Normalization error in node %ls.
205 16 All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
206 16 Operand type clash: %ls is incompatible with %ls
207 16 Invalid column name '%.*ls'.
instead of strings like '%.*ls', different words can be used. for example i have a string like this:
Invalid column name 'test'.
I want to use full-text search in Microsoft SQL Server 2012 to find most similar string in errors table with (Invalid column name 'test'.) i used below query but this query does not return any output
SELECT *
FROM errors AS A
INNER JOIN
CONTAINSTABLE(errors , text, 'ISABOUT ("Invalid column name ''text''")',
LANGUAGE N'English',10) AS K
ON A.text = K.[KEY]
any idea?
Related
I have a large data set on dbeaver (postgreSQL), and I am trying to filter for the following:
select * from raw_data_file where data_file_group_id = 2592 and dl_date = 2022-06-15
However, I am getting an error for the dl_date part of the filter- any suggestions?
SQL Error [42883]: ERROR: operator does not exist: date = integer¶ Hint: No operator matches the given name and argument types. You might need to add explicit type casts.¶ Position: 74
Stu's comment is correct. Use quotes, single quotes, otherwise the subexpression looks like a couple of subtractions.
We are using NHibernate over SQL Server and SQLite.
The database stores records in rows rather than columns -- each row having Path|Value as columns. Path and Value are both string properties.
For certain values of Path we would like to query for inequalities -- greater-than, less-than, etc.
The trouble we are having is that because the properties are strings, the inequalities are using string comparisons -- for example, searching for Value >= 18 returns rows where Value = 5. Unfortunately we are having trouble working around this.
1) This restriction produces incorrect results (saying 18 < 5):
Restrictions.Ge("Value", item.Value);
2) We tried casting the value to an integer, but this code produces a SqlException from NHibernate -- Error converting data type nvarchar to bigint.
Restrictions.Le(Projections.Cast(NHibernateUtil.Int64, Projections.Property("SearchString")), item.Value)
3) We were looking for a way to pad the property value with zeros (so that we would get 018 > 005), but could not find a way to do this in NHibernate.
Does anyone have any advice?
Thank you in advance!
Assuming that you want to compare on integer value, with IQueryOver:
1) This restriction produces incorrect results (saying 18 < 5):
Restrictions.Ge("Value", item.Value);
Restrictions.Ge
(
Projections.Cast(NHibernateUtil.Int32, Projections.Property<YourEntity>(x => x.YourProperty))
, intValue
)
Convert your datatype accordingly. If your C# datatype (intValue) is already numeric, no need to convert it. If your x.YourProperty is already numeric type, no need to convert it. Adjust above code accordingly.
2) We tried casting the value to an integer, but this code produces a SqlException from NHibernate -- Error converting data type nvarchar to bigint.
Restrictions.Le(Projections.Cast(NHibernateUtil.Int64, Projections.Property("SearchString")), item.Value)
Refer the above and check the datatype of item.Value.
I am trying to insert data from one table to another table, but we are facing issue it gives us error of
Numeric value out of range: 8115 [Microsoft][ODBC Driver 11 for SQL
Server][SQL Server ]Arithmetic overflow error converting varchar to
data type numeric. (SQLExecDirect[8115] at /builddir
/build/BUILD/php-5.6.30/ext/pdo_odbc/odbc_driver.c:247)
We are using below query to insert data
`INSERT INTO template_150 ([ClientName],[LOB],[PharmacyTotalClaimAmt])
SELECT PharmacyID,ProductIDNDC
, REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(decimal(10,2),CONVERT(varchar(10),CONVERT(varchar(10),LEFT
(SUBSTRING(REPLACE(TRIM(IngredCost),'\',''), PATINDEX('%[0-9.-]%',REPLACE(TRIM(IngredCost),'\','')),
8000),PATINDEX('%[^0-9.-]%', SUBSTRING(REPLACE(TRIM(IngredCost),'\',''), PATINDEX('%[0-9.-]%',REPLACE
(TRIM(IngredCost),'\','')), 8000) + 'X') -1)) )
),'"',''),'$',''),',',''),'-','') AS [TRIM(IngredCost)]
FROM file_5979bd211a3a9`
I found some solution to use lenth WHERE LEN(IngredCost
)<=13 function in where condition, but if we will use this function then we will not able to insert all the records for the table file_5979bd211a3a9, we want to save all the records of table file_5979bd211a3a9, can anyone please give us solutio, how can we resolve this error ?
You're converting a 10 character number to a DECIMAL(10,2). That means up to 8 digits in the whole portion and 2 in the fractional. If there are more than 8 numbers in the whole portion of the number, you can't convert that to a DECIMAL(10,2).
For example:
select convert(decimal(10,2),'1000000000')
Try DECIMAL(12,2) or use a VARCHAR(8).
I want to select and visualize the content of a column with CLOB datatype (>100 bytes).
select UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(ds_cirurgia,1,4000))
from AVISO_CIRURGIA
where cd_paciente = 123456789;
But I get this error:
[SELECT - 0 row(s), 0.000 secs] [Error Code: 997, SQL State: 42000] ORA-00997: illegal use of LONG datatype
I used UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR()) in another column and it works.
What is wrong in this case?
You can just leave it with the call to DBMS_LOB.SUBSTR: it returns a varchar2:
select DBMS_LOB.SUBSTR(ds_cirurgia,1,4000)
from AVISO_CIRURGIA
where cd_paciente = 123456789
However, keep in mind that Oracle SQL is only capable of having a varchar2 with 4000 bytes, not 4000 characters. Your call can fail if the string contains Unicode characters.
Your column type is LONG not CLOB. Simple look up it in USER_TAB_COLUMNS.
Here are some workaround how to resolve it. I'd recoment to change the type to CLOB with CTAS.
create table t1 as
select ...
to_lob(c) c /* convert to CLOB */
from t;
After that you can simple cast to VARCHAR such as
cast (substr(col_name,1,4000) as varchar2(4000))
UPDATE
of course you may also use DBMS_LOB.SUBSTR
DBMS_LOB.SUBSTR(col_name,4000,1)
but please note the signature of this function: 2nd parameter is length, 3rd offset (not vice versa as in substr).
I have a table in SQL Server 2008
Table Name : tbl_device
Table Structure:
Column | Type
col1 | nvarchar(200)
Now when i try to insert data into this (it works for shorter cases but) and the string data is long i.e. with
LEN function it is 162
Still the server gives error :
Msg 8152, Level 16, State 4, Line 1
String or binary data would be truncated.
what should be the reason for it ??
There are trailing blanks in the string that generates the error message but they are not counted using len() function.