Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
When I want to use CONCATENATE in SQL Server:
CONCAT(year(dateadd(year, -1, left(t1.[FQuater], 4))), right(t1.[FFQuater], 2))
I get this error:
Column FQuater is of Varchar datatype.
Just use + which is available on older versions of SQL Server instead of concat which is only available from SQL Server 2012:
year(dateadd(year,-1,left(t1.[FQuater],4))) +''+ right(t1.[FFQuater],2)
To avoid nulls(if possible)
isnull(year(dateadd(year,-1,left(t1.[FQuater],4))),'') +''+ isnull(right(t1.[FFQuater],2),'')
EDIT: As #ravish.hacker mentioned, you can do it like this:
isnull(year(dateadd(year,-1,left(t1.[FQuater],4))),'') +''+ isnull(right(t1.[FFQuater],2),'') + ' '
Hoping you are using SQL Server 2012 or later.
Concat by itself is nothing. You need to use select or set.
For example.
Select CONCAT(year(dateadd(year,-1,left(t1.[FQuater],4))),right(t1.[FFQuater],2))
For SQL Server 2008 this will work:
DECLARE #FQuater NVARCHAR(100) = '20110826'
SELECT CAST(YEAR(DATEADD(YEAR, - 1, LEFT(#FQuater, 4))) AS NVARCHAR) + CAST(RIGHT(#FQuater, 2) AS NVARCHAR)
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have to create a list box control that contains all of the queries except for the system queries. Recall that system query names begin with the ~ character.
When I try to write SQL code in the row source (in the property sheet) for my frmQueries form I keep getting an error saying:
Syntax error (missing operator) in query expression:'[Type]=5 And Left([Name],1)<>"~" OORDER BY [Name]'
The code I entered is:
SELECT [Name] FROM MYSysObjects
WHERE [Type]=5 And Left([Name],1)<>"~"
OORDER BY [Name];
I am not sure why I am getting this error or how I can fix it.
OORDER should be ORDER, MYSysObjects should (presumably) be MSysObjects, and you can also replace Left([Name],1)<>"~" with [Name] not like "~*" (assuming MS Access instead of SQL Server).
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I was past a request to replace in a table called BODYCONTENT for the BODY column and references to old server with new server.
The vendor sent the following SQL, but it failed. Any ideas on this?
update BODYCONTENT
set BODY = replace(CAST(BODY AS nvarchar(MAX), 'https://oldserver.com', 'https://newserver.com');
Error:
Msg 102, Level 15, State 1, Line 23
Incorrect syntax near ','
You are missing a right parenthesis in the CAST before the comma
update BODYCONTENT
SET BODY = replace(CAST(BODY AS nvarchar(MAX)), 'https://oldserver.com', 'https://newserver.com');
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Using SQL Server 2010
For updating the tables i am using following line
update database1_ab..table1
For sp_depends i am getting error as "Incorrect syntax near '.'"
sp_depends database1_ab..table1
How to use sp_depends for referring other database tables in current database
regardless, you need to put it in single quotes... ie
sp_depends 'database1_ab..table1'
or
sp_depends '[database1_ab]..[table1]'
You can call all the sp_ -procedures also in different database like this:
database1_ab..sp_depends table1
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Following SQL
select replace (IBSECM.IBSECM582CTEXT1SHRT, 'Curtina', 'Curtine') from table IBSECM;
is giving following error:
ERROR at line 1:
ORA-00906: missing left parenthesis
What am I missing?
I am using an Oracle DB.
Simply remove table keyword:
select replace (IBSECM.IBSECM582CTEXT1SHRT, 'Curtina', 'Curtine') from IBSECM;
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
So as someone advised me yesterday I'm using SQL Fiddle since it's an easy way to test database queries and SQL programming in general but I'm getting this error:
Schema Creation Failed: ORA-01821: date format not recognized
This happens in the insert line. This usually works in Oracle and I selected in the combobox on top of the page Oracle 11g. So what's the problem?
create table Reparacoes(
numero_r int,
matricula char(8),
dataEntrada date,
constraint pk_carro primary key(numero_R),
constraint check_matricula check (regexp_like(matricula,'[[:number:]]{2}-[[:alpha:]]{2}-[[:number:]]{2}')));
insert into Reparacoes values (1,'S2-SS-12',to_date('yyyy-mm-dd','2013-11-10'));
By my own stupidity I was using the to_date wrongly. It's supposed to be like this:
to_date('2013-11-10','yyyy-mm-dd'));
and not like this:
to_date('yyyy-mm-dd','2013-11-10'));