Hi,
I am trying to concat an int with an nvarchar in my select:
select distinct(id + name)
from load
where name not like '%test%'
but I am getting an error saying:
Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the nvarchar value '灪愭楮敭' to a column of data type int.
My question is: how do you concat int and string in MS SQL Server. The equivalent in Oracle would be ||, I think.
Thanks for any help.
Mongodid you try this --
select distinct(cast(id as nvarchar) + name) ...
Showing posts with label selectselect. Show all posts
Showing posts with label selectselect. Show all posts
Tuesday, March 27, 2012
Thursday, March 22, 2012
Compute By Clause problem in SQL 2000
I am having a problem with this compute by clause
The statement is a simple select
Select col1, col2 from table1
where <where clause>
order by col1
Compute Sum(col2) by col1
I want the display to show details and group totals.
The error message I keep getting is
Server: Msg 410, Level 16, State 2, Line 1
COMPUTE clause #1 'BY' expression #1 is not in the order by list.
I have previously used the compute clause so I know it should work !!
Ay help will be appreciated - Thank you.This is working for pubs - I do not see the difference.
SELECT type, price
FROM titles
ORDER BY type
COMPUTE SUM(price) BY type|||I saw this very same example and did my query and it doesn't work. I don't have the pubs database so I created a titles table and inserted some data and then ran this same query and that too gave me the same error !!!
Originally posted by snail
This is working for pubs - I do not see the difference.
SELECT type, price
FROM titles
ORDER BY type
COMPUTE SUM(price) BY type|||Originally posted by CSC
I saw this very same example and did my query and it doesn't work. I don't have the pubs database so I created a titles table and inserted some data and then ran this same query and that too gave me the same error !!!
I am afraid you have a problem with your sql server - is it microsoft 2000?|||Yes it is Microsoft Sql Server 2000. This is really strange !!
Originally posted by snail
I am afraid you have a problem with your sql server - is it microsoft 2000?
The statement is a simple select
Select col1, col2 from table1
where <where clause>
order by col1
Compute Sum(col2) by col1
I want the display to show details and group totals.
The error message I keep getting is
Server: Msg 410, Level 16, State 2, Line 1
COMPUTE clause #1 'BY' expression #1 is not in the order by list.
I have previously used the compute clause so I know it should work !!
Ay help will be appreciated - Thank you.This is working for pubs - I do not see the difference.
SELECT type, price
FROM titles
ORDER BY type
COMPUTE SUM(price) BY type|||I saw this very same example and did my query and it doesn't work. I don't have the pubs database so I created a titles table and inserted some data and then ran this same query and that too gave me the same error !!!
Originally posted by snail
This is working for pubs - I do not see the difference.
SELECT type, price
FROM titles
ORDER BY type
COMPUTE SUM(price) BY type|||Originally posted by CSC
I saw this very same example and did my query and it doesn't work. I don't have the pubs database so I created a titles table and inserted some data and then ran this same query and that too gave me the same error !!!
I am afraid you have a problem with your sql server - is it microsoft 2000?|||Yes it is Microsoft Sql Server 2000. This is really strange !!
Originally posted by snail
I am afraid you have a problem with your sql server - is it microsoft 2000?
Subscribe to:
Posts (Atom)