My name is Devkranth .. i need help in sql.... i have 3 tables to retrieve data and display it.. there is no Primary key in any table.. but there is a common column , so if i join the tables i am getting rows duplicated... plz help me..
Although you don't have to call Close() it is advisable. While the DataReader is open you are tying up the connection so it cannot be used until the reader has been collected by the garbage collector. You don't have any control over when the garbage collector will collect the reader.
Another option is to wrap it in a using statment and have C# close it when it drops out of scope
using(SqlDataReader dr = cmd.ExecuteReader())
// Do stuff.
I am doing a project in Visual Studio .net (language C#). How can I store documents (like Word, Excel, PPT etc.) in an SQL server 2000.
Please can anybody provide some useful links or the exact method/code.
Yes Sure you can do that. All what you need to do is add parameters to your insert statment.
insert into temptable (col1,col2) values (@username,@date)
the @username and @date are the parameters you have to assign values to in you command object.
mycommand.parameters.add("@username","Value of the username")
mycommand.parameters.add("@date","Value of the date")
there is a new ctrlkey on every 6 rollnos
I want Output Should like this :
Rollno Marks (like Foreign Key)
Please help me to write a single select query to get output.
1. Create a cursor for "Marks" table
2. create a cursor for "Ctrl" table which fetches corresponding data for hte ctrlkey fetched by outer cursor
3. in the inner look you can arrange the data as you required
This may seem a simple question, but I'm not looking for a solution, I'm looking for a best practice. I have a SQLTable that contains 293 columns, and may even contain thousands of rows. Such a massive table could be a source of performance issues.
My question is: Is it satisfactory to keep the table this way, or should it be better if I divide the table on more than one tables, and link them using Foreign Key constraints? For example each Table containing 50 columns or so?
Waiting eagerly for your expertise concerning this issue.
I have a SQLTable that contains 293 columns, and may even contain thousands of rows. Such a massive table could be a source of performance issues.
Absolutely - But, it really depends on how you want to use the table.
Nader Elshehabi wrote:
Is it satisfactory to keep the table this way, or should it be better if I divide the table on more than one tables, and link them using Foreign Key constraints?
To me that suggests that the table is not normalised. All data in the table must be dependent on the primary key. If you have repeating data in a table that suggests that a separate table needs to be created. For example:
A table Family: MotherName, FatherName, Child1Name, Child2Name, Child3Name, Child4Name
This has some limitations. First a maximum of 4 children are permitted. It assumes everyone lives in a perfect home and all siblings share the same parents.
So, if you have repeating columns (often characterised by the need to include a digit) then that needs to be separated out into a new table.
Nader Elshehabi wrote:
For example each Table containing 50 columns or so?
You should search for useful relationships rather than splitting at an arbitrary number of columns. By splitting at every 50th column you run the risk of splitting related data (or data that is often used together) into separate tables which will slow down any query.
If there is no way to normalise the data then consider what groups of columns tend to be used together. Then split it that way ensuring that each table maintains a one-to-one relationship with the others. This will cause some issues during an insert where some rows won't exist yet. So, design it to accept a zero-to-one relationship - that way missing rows in other tables don't affect the whole. You might also find that there a groups of columns where if one column isn't filled, neither are others in the group. You can then use this knowledge to eliminate the need to store a row where no information is used.