October 19, 2005 at 4:39 am
Hi,
When i run the follwoing query
select * from dbo.Part_Mast
where Part_Num in (select convert(varchar,convert(datetime,Date_Lst_Iss),103), Part_Num from dbo.Part_Mast where Part_Num LIKE (RTRIM('258095GB') + '%'))
order by Part_Num
i get the follwoing error
Server: Msg 116, Level 16, State 1, Line 1
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Can anyone help?
Thanx
October 19, 2005 at 5:09 am
Hi!!!
In ur subquery that getting two columns as output which compar with one column from outer query......
by removing convert(varchar,convert(datetime,Date_Lst_Iss),103) u will get output...
select * from dbo.Part_Mast
where Part_Num in (select Part_Num from dbo.Part_Mast where Part_Num LIKE (RTRIM('258095GB') + '%'))
order by Part_Num
Regards,
Papillon
October 19, 2005 at 6:19 am
Hi,
But I need that query, thats the query im trying to add to the orginal sql query. I'm trying to make it work with that query.
any suggestions
Thanx
October 19, 2005 at 6:30 am
Hi!!!!
U can do....
select * into #temp from (select Part_Num from dbo.Part_Mast where Part_Num LIKE (RTRIM('258095GB') + '%')) p
and now u can use....
select * from dbo.Part_Mast
where Part_Num in (select Part_Num from #temp)
order by Part_Num
Drop table #temp
...
Regards,
Papillon
October 19, 2005 at 6:32 am
yes but what about the date?
October 19, 2005 at 6:37 am
Hi!!!
Actually that was my mistake u should write this way.....
select * into #temp from (select convert(varchar,convert(datetime,Date_Lst_Iss),103),Part_Num from dbo.Part_Mast where Part_Num LIKE (RTRIM('258095GB') + '%')) p
Regards,
Papillon
October 19, 2005 at 7:00 am
select * into #temp from
(select convert(varchar,convert(datetime,Date_Lst_Iss),103), Part_Num from dbo.Part_Mast
where Part_Num LIKE (RTRIM('258095GB') + '%'))
select * from dbo.Part_Mast
where Part_Num in (select Part_Num from #temp)
order by Part_Num
drop table #temp
I get a syntax error
October 19, 2005 at 7:09 am
Hi!!!!!
as seen ur post ur not alias subquery here..
select * into #temp from (select convert(varchar,convert(datetime,Date_Lst_Iss),103),Part_Num from dbo.Part_Mast where Part_Num LIKE (RTRIM('258095GB') + '%')) P
and then run this ......
select * from dbo.Part_Mast
where Part_Num in (select Part_Num from #temp)
order by Part_Num
Drop table #temp
Hope that will clear u.........
Regards,
Papillon
October 19, 2005 at 7:49 am
even when I run the first query first i get a bracket error where as they are no extra brackets also im running both the queries in a stored proceudre so i will be running them together.
October 19, 2005 at 7:58 am
hi!!!!
Can u give me which query u run ...and what error msg u got there......
Regards,
Papillon
October 19, 2005 at 8:46 am
select * into #temp from
(select convert(varchar,convert(datetime,Date_Lst_Iss),103), Part_Num from dbo.Part_Mast
where Part_Num LIKE (RTRIM('258095GB') + '%'))
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near ')'.
October 19, 2005 at 9:01 am
select P.* into #temp from
(select convert(varchar,convert(datetime,Date_Lst_Iss),103), Part_Num from dbo.Part_Mast
where Part_Num LIKE (RTRIM('258095GB') + '%')) P
October 19, 2005 at 9:02 am
SELECT *
INTO #temp
FROM( SELECT CONVERT( varchar, CONVERT( datetime, Date_Lst_Iss, 103)), Part_Num
FROM dbo.Part_Mast
WHERE Part_Num LIKE( RTRIM( '258095GB') + '%'))
I wasn't born stupid - I had to study.
October 19, 2005 at 9:09 am
Whoa..
..what was the question again? I mean, do you need all this temptable juggling in the first place?
Could the original poster perhaps state the real problem - that is what is your intentions? Please also provide some simple example that shows what your data and tables look like. Then - when we have agreed upon what to solve, we can think of something
/Kenneth
October 19, 2005 at 11:58 am
Am I missing something ?
Doesn't this SQL do the job ?
select *
, convert(varchar,convert(datetime,Date_Lst_Iss),103)
from dbo.Part_Mast
where Part_Num LIKE '258095GB%'
order by Part_Num
SQL = Scarcely Qualifies as a Language
Viewing 15 posts - 1 through 15 (of 24 total)
You must be logged in to reply to this topic. Login to reply