Tuesday, March 20, 2012
Save system stored procedure results?
table? Example - I want to run xp_fixeddrives and send the results to a
temp table. Is this possible?
Rachael
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!Yes, here's some quick code:
CREATE TABLE #FixedDrivesOutput
(
Drive char(1),
MBFree int
)
GO
INSERT INTO #FixedDrivesOutput (Drive, MBFree)
EXEC master.dbo.xp_fixeddrives
--
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Rachael Faber" <rfaber@.alldata.net> wrote in message
news:Onzn0A5YEHA.2816@.TK2MSFTNGP11.phx.gbl...
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!|||Hey -
How are you running the SP, ie.. from Query Analyzer, from isql ?
If from Query Analyzer you can save .CSV file or any other type of file and
then load it into a table.
If from isql, redirect the output to a file and then load it into a table.
HTH
"Rachael Faber" <rfaber@.alldata.net> wrote in message
news:Onzn0A5YEHA.2816@.TK2MSFTNGP11.phx.gbl...
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!|||Rachel
try do to something like this
-- Create a table with the same structure that the procedure returns
Create table tempdb.dbo.sphelpdb( name_1 varchar(255), db_size varchar(255), owner varchar(255), db_id int ,created varchar(255), status varchar(255))
-- Insert into the table the results got using a EXEC and procedure with parameters
Insert tempdb.dbo.sphelpdb(name_1, db_size, owner, db_id, created, status)
EXEC('sp_helpdb')
-- Voila! the table contains, the procedure results.
Select * from tempdb.dbo.sphelpdb
"Rachael Faber" wrote:
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
>
Save system stored procedure results?
table? Example - I want to run xp_fixeddrives and send the results to a
temp table. Is this possible?
Rachael
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!Yes, here's some quick code:
CREATE TABLE #FixedDrivesOutput
(
Drive char(1),
MBFree int
)
GO
INSERT INTO #FixedDrivesOutput (Drive, MBFree)
EXEC master.dbo.xp_fixeddrives
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Rachael Faber" <rfaber@.alldata.net> wrote in message
news:Onzn0A5YEHA.2816@.TK2MSFTNGP11.phx.gbl...
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!|||Hey -
How are you running the SP, ie.. from Query Analyzer, from isql ?
If from Query Analyzer you can save .CSV file or any other type of file and
then load it into a table.
If from isql, redirect the output to a file and then load it into a table.
HTH
"Rachael Faber" <rfaber@.alldata.net> wrote in message
news:Onzn0A5YEHA.2816@.TK2MSFTNGP11.phx.gbl...
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!|||Rachel
try do to something like this
-- Create a table with the same structure that the procedure returns
Create table tempdb.dbo.sphelpdb( name_1 varchar(255), db_size varchar(255),
owner varchar(255), db_id int ,created varchar(255), status varchar(255))
-- Insert into the table the results got using a EXEC and procedure with par
ameters
Insert tempdb.dbo.sphelpdb(name_1, db_size, owner, db_id, created, status)
EXEC('sp_helpdb')
-- Voila! the table contains, the procedure results.
Select * from tempdb.dbo.sphelpdb
"Rachael Faber" wrote:
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
>|||Thanks for the suggestions. That's exactly what I needed!
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Save system stored procedure results?
table? Example - I want to run xp_fixeddrives and send the results to a
temp table. Is this possible?
Rachael
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Yes, here's some quick code:
CREATE TABLE #FixedDrivesOutput
(
Drive char(1),
MBFree int
)
GO
INSERT INTO #FixedDrivesOutput (Drive, MBFree)
EXEC master.dbo.xp_fixeddrives
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
"Rachael Faber" <rfaber@.alldata.net> wrote in message
news:Onzn0A5YEHA.2816@.TK2MSFTNGP11.phx.gbl...
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
|||Hey -
How are you running the SP, ie.. from Query Analyzer, from isql ?
If from Query Analyzer you can save .CSV file or any other type of file and
then load it into a table.
If from isql, redirect the output to a file and then load it into a table.
HTH
"Rachael Faber" <rfaber@.alldata.net> wrote in message
news:Onzn0A5YEHA.2816@.TK2MSFTNGP11.phx.gbl...
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
|||Rachel
try do to something like this
-- Create a table with the same structure that the procedure returns
Create table tempdb.dbo.sphelpdb( name_1 varchar(255), db_size varchar(255), owner varchar(255), db_id int ,created varchar(255), status varchar(255))
-- Insert into the table the results got using a EXEC and procedure with parameters
Insert tempdb.dbo.sphelpdb(name_1, db_size, owner, db_id, created, status)
EXEC('sp_helpdb')
-- Voila! the table contains, the procedure results.
Select * from tempdb.dbo.sphelpdb
"Rachael Faber" wrote:
> Is there a way to save the results of a system stored procedure into a
> table? Example - I want to run xp_fixeddrives and send the results to a
> temp table. Is this possible?
> Rachael
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
>
|||Thanks for the suggestions. That's exactly what I needed!
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Monday, March 12, 2012
Save excel records into SQlserver
anybody give example code for save Excel records into sqlserver in asp.net1.1
Thanks
Do you must have this done in ASP .NET 1.1 code? SQL Server its self has some features to import data from EXCEL, for example Import/Export Wizard, DTS, bcp utility, etc. The most straight way is using Import/Export Wizard in Enterprise Manager (or Management Studio for SQL2005).
You can take look at this KB:
http://support.microsoft.com/default.aspx?scid=kb;en-us;321686
Friday, March 9, 2012
save and retrieve RTF TEXT FROM SQL DATABASE
Hi,
i have a richtextbox control in my application, and want to know how to save and retrieve formatted text in a MS SQL DB.
I found this example in the forum, but I don't know how to use it. Can you please help me solve the problem? Where should I write the code below?
I've just tried it and able to do this successfully.
I basically did this:
load the RTF into the RTB control created a SQL command, simple basic insert statement:
SqlCommand theSQLCommand = new SqlCommand("INSERT INTO [TableName] (Field) VALUES (@.p1)");
SqlParameter theSQLParameter = new SqlParameter("@.p1", SqlDbType.Text);
theSQLParameter.Value = this.theRichTextBox.RTF;
theSQLCommand.Parameters.Add(theSQLParameter);
theSQLCommand.Connection = new SqlConnection(ConnectionString);
theSQLCommand.Connection.Open();
theSQLCommand.ExecuteNonQuery();
theSQLCommand.Connection.Close();
then to retrieve it, I did this, again, specifically for this example
this.theRichTextBox.Text = String.Empty;
SqlCommand theSQLCommand = new SqlCommand("SELECT [Field] FROM [TableName] WHERE [ID] = 1");
theSQLCommand.Connection = new SqlConnection(ConnectionString);
theSQLCommand.Connection.Open();
SqlDataReader theReader = theSQLCommand.ExecuteReader(CommandBehavior.CloseConnection);
while (theReader.Read())
{
this.theRichTextBox.RTF = theReader.GetValue(0).ToString();
}
theSQLCommand.Connection.Close();
And was able to do this fine and got all the formatting etc... correctly.
The two block codes are from a Windows Forms .NET application with a richtextbox control called theRichTextBox. You would just need to create a table with a column of type TEXT and replace the appropriate [Field] and [TableName] values with the table and column as appropriate. Also, (hopefully obviously) you would need to replace ConnectionString with the parameters to connect this to your specific database.Tuesday, February 21, 2012
Samples for Calendar Style Reports
Want to see sample reports that display
the data in calendar format like outlook does.
Example ... all appointments for the next 2 weeks arranged
as a calendar.
Thank you for your help in advance.It depends on which Outlook view. Month? Week? Day? You probably could
get the day view or business week view working using tables as well as a
dataset that included all days and hours, and outer join your appointments
so you could display the entire range of data and leave the non-appointments
blank.
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"Rakesh" <Rakesh@.discussions.microsoft.com> wrote in message
news:EAEA54D3-82E2-44B4-8AB0-4FEC73A79266@.microsoft.com...
> newbee! question.
> Want to see sample reports that display
> the data in calendar format like outlook does.
> Example ... all appointments for the next 2 weeks arranged
> as a calendar.
> Thank you for your help in advance.
>
Sample on how to import Flat File with vertical structure
Hello,
I'm looking for an example on how to import a Flat file that is not a csv file but had data on several lines, a small indicator at the beginning of the line indicates what kind of data is on the rest of the line. Not every field is availabye for each block.
Anybody got an idea on where to find this kind of samples.
Thx.
? Harry, I think the inconsistency in which columns are present or not in each row is going to cause you problems in SSIS. If I understand your structure correctly you can't use the Flat File Connection manager for such data. I think you'll need to write some custom code. Without knowing the structure of your data I don't think I can be more specific. Andrew Watt [MVP] <Harry_Leboeuf@.discussions.microsoft.com> wrote in message news:22ebb616-102a-46db-b372-9c21df0d6f3f@.discussions.microsoft.com... Hello, I'm looking for an example on how to import a Flat file that is not a csv file but had data on several lines, a small indicator at the beginning of the line indicates what kind of data is on the rest of the line. Not every field is availabye for each block. Anybody got an idea on where to find this kind of samples. Thx.|||Harry_Leboeuf wrote:
Hello,
I'm looking for an example on how to import a Flat file that is not a csv file but had data on several lines, a small indicator at the beginning of the line indicates what kind of data is on the rest of the line. Not every field is availabye for each block.
Anybody got an idea on where to find this kind of samples.
Thx.
I personally would import each row as simply a single column of type DT_STR/DT_WSTR and then parse out the required columns within the data-flow - probably using a script component.
You could make things slightly easier for yourself by importing the data as two columns: the first contains the indicator and the second contians the rest of it.
Alternatively you could combine those two steps into one and write a source component that imported the data and parsed it on the way. I wouldn't do that though cos there's no point in creating work for yourself - let SSIS import the data and you are then left with the relatively easy job of parsing out the columns.
-Jamie
Sample Function in SQl Server 2005
hi good day everyone, is there any link where we can find the sample how to create function in Sql Server 2005.
example i would like to search that gives me specific person based on the parameter given.
thanks
Here's the doc on how to create function.
http://msdn2.microsoft.com/en-us/library/ms186755(SQL.90).aspx
However, a function may or may not be what you need. How are you going to be invoking and using this?