SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL - SELECT statement


SQL - SELECT statement

Author
Message
Flavio Bendl
Flavio Bendl
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 50

Dear All.

I am receiving this error message "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS" to the statement below :

declare @tamanho as varchar(10)
SET @tamanho= (select substring(name,1,30) as Banco,
CAST( ( FILEPROPERTY( name, 'SpaceUsed' ) * 8 ) / 1024 AS numeric( 10, 2) )
FROM sysfiles)
go

Please, somebody can help...

Thanks,

Flavio Bendl


Ray M
Ray M
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4975 Visits: 1076

Well,

If you execute this code alone, how many records are returned?

select substring(name,1,30) as Banco,
CAST( ( FILEPROPERTY( name, 'SpaceUsed' ) * ) / 1024 AS numeric( 10, 2) )
FROM sysfiles

More than 1.

So which one do you want to use to set the variable to?


sswords
sswords
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2212 Visits: 84

IANAD, (I am not a developer) but see if this helps:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_qd_11_9nw3.asp



My hovercraft is full of eels.
David A. Long
David A. Long
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2219 Visits: 237

Try:

declare @tamanho varchar(10)
select @tamanho=substring(name,1,10),
--CAST((FILEPROPERTY(name, 'SpaceUsed')* 8)/1024 AS numeric(10,2))
FROM sysfiles

SELECT @tamanho

or:

declare @tamanho varchar(10)
select @tamanho=
--substring(name,1,30) as Banco,
CONVERT(varchar(10),CAST((FILEPROPERTY(name, 'SpaceUsed')* 8)/1024 AS numeric(10,2)))
FROM sysfiles

SELECT @tamanho

or:

declare @tamanho numeric(10,2), @banco varchar(30)
select @banco=substring(name,1,30),
@tamanho=CAST((FILEPROPERTY(name, 'SpaceUsed')* 8)/1024 AS numeric(10,2))
FROM sysfiles

SELECT @banco, @tamanho

Andy





bledu
bledu
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2907 Visits: 104
i think the question we should be asking Flavio is 'What do you want to do?' before we suggest any solution


Everything you can imagine is real.

Flavio Bendl
Flavio Bendl
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 50

Dear All,

I need to make a monthly control on disk space on SQL 2000 Server. I have 3 servers.

I thought to create a table and to insert the SELECT result in table.

I don’t know very well SQL 2000 and DBA procedures.

If somebody knows some procedure to make it, please help me.

*****Replay to David A. Long

Your select is returning only one record (Log file) . I would like seeing all records this table, but, it´s very good.

Thank you


sswords
sswords
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2212 Visits: 84

See if this article helps.

http://www.sqlservercentral.com/columnists/mnash/monitoringdriveanddatabasefreespace.asp



My hovercraft is full of eels.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search