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


Problem with inserting the data into temp table


Problem with inserting the data into temp table

Author
Message
Shadab Shah
Shadab Shah
SSC-Addicted
SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)

Group: General Forum Members
Points: 439 Visits: 798
Hi all,

I am trying to stored the output of sp_spaceused into a temp table as follow.


if exists (select 1 from sys.objects where object_id=OBJECT_ID(N'#TEMP'))

create table #temp (name nvarchar(50),rows nvarchar(50),reserved nvarchar(50),data nvarchar(50),index_size nvarchar(50),unused nvarchar(50))
insert into #temp
exec sp_spaceused 'dbo.Emp'



i am getting the error as below
Msg 8114, Level 16, State 1, Procedure sp_spaceused, Line 178
Error converting data type varchar to int.



Now if we observed closely in my temp table there isn't any column with datatype as int.So i am not able to figure it out, why is it trying to convert the column to int when it can stored it nvarchar.
John Mitchell-245523
John Mitchell-245523
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14030 Visits: 15944
The error is occurring in the stored procedure itself. Do you get the same error if you run just the EXEC line?

John
Shadab Shah
Shadab Shah
SSC-Addicted
SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)

Group: General Forum Members
Points: 439 Visits: 798
John Mitchell-245523 (1/9/2013)
The error is occurring in the stored procedure itself. Do you get the same error if you run just the EXEC line?

John


No, it is not giving me the error it is actually giving me the result of sp_spaceused
John Mitchell-245523
John Mitchell-245523
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14030 Visits: 15944
The your first statement should start IF NOT EXISTS, should it not? In any case, please post the results of the following query:
SELECT * FROM tempdb.INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME LIKE '#temp%'



John
Shadab Shah
Shadab Shah
SSC-Addicted
SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)

Group: General Forum Members
Points: 439 Visits: 798
John Mitchell-245523 (1/9/2013)
The your first statement should start IF NOT EXISTS, should it not? In any case, please post the results of the following query:
SELECT * FROM tempdb.INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME LIKE '#temp%'



John



Ooppss.....My Apologies.
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