December 9, 2008 at 9:15 am
I have a DBCC Statement, for which i get results into the table.
Like this;
Create table #getlogspace
(
dbname varchar(100) null,
[logsize(MB)] varchar(10) null,
[LogSpaceUser(%)] varchar(10) null,
status int
)
--insert DBCC values into this Table
insert into #getlogspace
EXEC ('DBCC SQLPERF(LOGSPACE)')
---------- This Above Works Fine.----------------
-----------Real Trouble Starts here--------------
But when create the above table with additional Columns :
Create table #getlogspace
(
infodate datetime null ,
servername nvarchar(50) null ,
dbname varchar(100) null,
[logsize(MB)] varchar(10) null,
[LogSpaceUser(%)] varchar(10) null,
status int
)
I am unable to execute the above insert statement with Tweaks.
What i do for now is Create Table without the infodate,servername columns and do the plain insert, then add column to the table and i do an update on the column to fill the values for the 2 clumns.
I want to insert the value in all columns in ONE GO....
Pl Help.
Maninder
www.dbanation.com
December 9, 2008 at 9:43 am
if the destination table has the eXACT same structure as the SELECt/DBCC, you do not need to mention the columns...since you added some extra fields, you have to explicitlu name the columns for the insert:
insert into #getlogspace([dbname],[logsize(MB)],[LogSpaceUser(%)],[status])
EXEC ('DBCC SQLPERF(LOGSPACE)')
Lowell
December 9, 2008 at 9:47 am
Exactly, here is what i did.
I defined DEFAULT for the columns(infodate and servername) and then applied the insert.
GREAT, thanks and ton.
Maninder
www.dbanation.com
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy