Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Monday, March 19, 2012

How can I list the students in the CIS department? (SQL Server Query)

I need to write the SQL script for the above question.

Student table contains students' IDs, names, Addresses.

MajorMinor table contains 4 departments with unique code.
Name is a field and CIS is an attribute. Code(primary key) is a field and CIS is 13.

Student declares major. Declares table has StudentID and MajorMinorCode. The only student, his StudentID is 3579, has MajorMinorCode 13. (Meaning he is the only student who declared CIS as his major.)

I created and populated my database in SQL Server Management.

I am having trouble if I am selecting 2 tables or just one table with any other clauses?
Any help is appreciated! Thanks!That looks like an assignment / home work .

Can you kindly post what you have tried to solve the mentioned problem.|||

Quote:

Originally Posted by debasisdas

That looks like an assignment / home work .

Can you kindly post what you have tried to solve the mentioned problem.


Here you go.
SELECT Student.Name
FROM (Student INNER JOIN Declares ON Student.ID = Declares.StudentID) INNER JOIN MajorMinor ON Declares.MajorMinorCode = MajorMinor.Code
WHERE ((MajorMinor.Name)="CIS"));

Friday, March 9, 2012

How can I insert SP's result set to a table

hello,
the stored proc sp_help_job @.execution_status = 1 return
one row.
How can I insert this row to a table? Can I write a
statemate like:
Select *
into tableA
from
(exec sp_help_job @.execution_status = 1)
Can anybody tell me how to do it?
Thanks a lot...hi Harry,
See following example.
CREATE TABLE #Temp1
(
spid varchar(32),
dbid real,
objid real,
indid int,
type varchar(50),
resource varchar(50),
mode varchar(5),
status varchar(5)
)
-- following is the syntax.
INSERT INTO #Temp1 EXEC sp_lock
-- Vishal

How can I insert SP's result set to a table

hello,
the stored proc sp_help_job @.execution_status = 1 return
one row.
How can I insert this row to a table? Can I write a
statemate like:
Select *
into tableA
from
(exec sp_help_job @.execution_status = 1)
Can anybody tell me how to do it?
Thanks a lot...hi Harry,
See following example.
CREATE TABLE #Temp1
(
spid varchar(32),
dbid real,
objid real,
indid int,
type varchar(50),
resource varchar(50),
mode varchar(5),
status varchar(5)
)
-- following is the syntax.
INSERT INTO #Temp1 EXEC sp_lock
-- Vishal

Friday, February 24, 2012

How can I get rid of the comma in a company name by using sql command?

For example: company_name: ABC company, inc.

I want to get rid of the comma, replace by a space. How the query should be write?

Thanks

replace(ColumnName,',',' ')

example

select replace('ABC,ZXX',',',' ')

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||Thank You!!!

Sunday, February 19, 2012

How can I generate variables automatically?

Hi there

I need to generate some variables , like var1, var2, var3 ...

It's determined by how many records in my database.

I want to write a for() to do this. But how?

For example

for(int i=0; i<datatable.rows.count; i++)
{
String vari = new String;
}

This is not a right way in C#, does anyone know how to?

Thanks!!!

int _intTotalRowCount=0;

_intTotalRowCount=DataBaseTable.RowsCount;

string _strVar ="";for (int _intCount = 0; _intCount <_intTotalRowCount; _intCount++)

{

_strVar = _strVar+","+ "Var" +_intCount.ToString();

}

Label1.Text= _strVar;

How can I FTP 3 files

Hello,

I am new to SSIS.

I am trying to write a simple package that saves data into some tables from elsewhere in the database, extracts it into flat files and then FTPs them to another file system.

I have a control flow with three tasks. [1] Execute SQL (Executes a stored proc to fill the tables with data) [2] A data flow to extract the data into 3 flat files [3] An FTP task to move the data to the other system.

In my data flow I have three parallel streams each with an OLE-DB source and a Flat file destination so that three flat s files get produced in parallel.

The problem I have is that I cant get the FTP task to handle the files. I can get the flat files produced fine and I write them to the c: drive. But how do I program the FTP transform to pick up the three files and dispatch them? I am guessing that I need to edit the FTP task, choose the file transfer tab and edit the local parameters section to tell it to pick up the three files........but how?

As mentioned I am new to SSIS so simple+clear answers appreciated.

Thanks in advance

MGale1

This is a completely reasonable request. What I would recommend is to put each file you create in a ForEach Loop Container. Each time you loop to create a new file, inside the loop you can use the FTP Task to send the one file. You can dynamically set the file you wish to send by setting an expression on the Connection Manager that holds the file's name. I know I didn't specify exactly how to each step but you can see a more in depth about how to use SSIS expressions to set the package to be dynamic here: http://www.jumpstarttv.com/Media.aspx?vid=34.

I know you mentioned that you wanted to create the file inside the same data flow. Unfortunately, the files will have to be FTP individually to the destination. If you were to receive files from a FTP site, the task accepts wild cards (give me all the *.txt files from the ftp server). When you send files though, it's a different story. SSIS is going to force you to use a File Connection Manager to specify which file you wish to send. You cannot send multiple files at one time other than doing it in a loop as I mentioned above. At least, I'm not sure of a way to do it :).

For a slew of SSIS how-to starter videos, you can see this link: http://www.jumpstarttv.com/Channel.aspx?cat=c871236d-8554-42e3-8683-4d422356c0bd

|||From what you've written, it sounds like you could use three FTP tasks, one for each file.