For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I have a SQL table with some existing data. In that I have a columns named "Name" and SL No (which is a primary key). For example say I have one entry for that column as "Thilak". Suppose if a next entry comes with same name i.e "Thilak", I want to rename the existing "Thilak" as "Thilak_Slno" and new entry as "Thilak_Slno". And If again any Thilak repeats I want append serial number to that before saving or soon after saving to the database.
The purpose is simple, I am giving option to post a query in my software based on username. while selecting the name, if same name exists in entry that will be difficult to select the Name, if name comes with serial number it will be easier.
So whenever a new entry comes which is same as the existing name, I am planning to append the serial number to the existing names also to the incoming name.
So, now whether it is possible to change the name as it enters into the table ? or should I change once it get saved to database ?
If you want all names to be unique, then just add the serial number in the first place. Then you do not need the extra steps of searching for an existing name and changing it when adding to your database. Alternatively just accept that there may be duplicates which you can process when searching.
You shouldn't change it at all. They are two separate facts, and should each be in their separate field. That way you don't need to "substring" on the name when the numbering changes, and can easily add another field if your combination is no longer unique.
The database is not there to store "formatted" values, but data. Upon retrievel, you paste to two fields together and have what you want.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
i have been using the below declared Cursor from the Stored-procedure for around 3 years now. The last couple of weeks i have been getting the error
Incorrect syntax near the keyword 'CROSS'.
I dont have a Cross Join in this Cursor and this started after Infrastructures upgraded the hardware on the SQL Server , i noticed other settings were lost but was able to recover them.
GO/****** Object: StoredProcedure [dbo].[DATABASE_MAINTANANCE_PLAN] Script Date: 5/22/2010 12:32:30 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO/*THIS SP WILL REBUILT ALL THE INDEXES IN ALL TABLES IN ALL DATABASES
THIS WILL BE CALLED FROM AN SSIS PACKAGE. THIS WILL USED IN CLIENTS TO REBUILT INDEXES AND IT WILL BE
RAN EVERY FRIDAY NIGHT
ASDECLARE@DatabaseName SYSNAME = DB_NAME(), @TableNameVARCHAR(256)
DECLARE@FILLFACTORINT = 85DECLARE@DynamicSQLNVARCHAR(max) =
'DECLARE curAllTablesInDB CURSOR FOR SELECT TABLE_SCHEMA +
''.'' + TABLE_NAME AS TABLENAME
FROM ' + @DatabaseName + '.INFORMATION_SCHEMA.TABLES WHERE
TABLE_TYPE = ''BASE TABLE'''BEGINEXEC sp_executeSQL @DynamicSQL-- create tables cursor
FETCH NEXT FROM curAllTablesInDB INTO@TableNameWHILE (@@FETCH_STATUS = 0)
BEGINSET@DynamicSQL = 'ALTER INDEX ALL ON ' + @TableName +
' REBUILD WITH (FILLFACTOR = ' + CONVERT(VARCHAR,@FILLFACTOR) + ')'PRINT@DynamicSQL-- ALTER INDEX ALL ON Purchasing.ShipMethod REBUILD WITH (FILLFACTOR = 85)
EXEC sp_executeSQL @DynamicSQLFETCH NEXT FROM curAllTablesInDB INTO@TableNameEND-- cursor WHILE
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
I am planning to migrate from MSFlexGrid to MsHflexGrid. In MSFlexGrid, when the .col /.row property is changed programmatically, the rowcolchange event gets fired. But in MsHflexGrid the same doesn’t work. However, on manually changing the .col/.row property through mouse click or using navigation keys, the event gets fired in MSHFlexGrid
I am using Microsoft SQL server 2008. I have 2 SQL tables Table 'Product1' and Table 'Product2'. In 'Product1' Table I have columns named
And 'Product2' have columns named,
here 'regno' if FK to 'SLNO' (of product1 table ).
My requirement is to update the columns in 'Product2' table when I modify data in 'Product1' table ( 'name' 'Place' and 'state' column).
Is it possible to update 'Product2' table without running individual queries for each rows ?
Is it possible to set ''ON DELETE CASCADE" without adding primary key in the parent table ?
A foreign key must reference either a primary key, or a column with a unique constraint. To set up a foreign key between the tables, you'll need a unique constraint on the SLNO column in table1.
But I want to add "ON DELETE CASCADE" only for Place and State.
I don't think you've understood what ON DELETE CASCADE means. When you delete the row from table1, any rows in table2 with the same SLNO will be deleted as well. It doesn't do anything when you change a value in the referenced row, and it doesn't delete the value from specific columns.
You could do this with a trigger[^] on table1, but it's a pretty nasty workaround, which can lead to hard-to-trace problems. As it's only two tables, it would be simpler to update both at the same time.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Now I have a doubt,
I want to another column named 'regno' and I want to make it primary key of product1. Now is it possible to add FK in prodcut2 for regno, name, state and place. ?
Because I am getting an error..
Introducing FOREIGN KEY constraint 'FK_ProductDetails_Products' on table 'Product2' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
In my case,
regno refers to Prooduct1's regno ( which is primary key)
name, place and state refers to Prooduct1's name, place and state ( which are unique constraints )
[A] table cannot appear more than one time in a list of all the cascading referential actions that are started by either a DELETE or an UPDATE statement.
You're trying to use a foreign key for something that it wasn't designed for. If you can't change the table design, switch to issuing multiple queries, or using a trigger to push the changes from Product1 to Product2.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I would suggest you spend some time understanding Normalization of tables and reference integrity. If you have a good understanding of these concepts then it will be a lot easier for you designing the tables in the right way and fixing any errors.
I think you're looking for GROUP_CONCAT()[^]. As far as I understand it, you don't need the grouping aspect of it but there doesn't seem to be an equivalent function without it. So you need to provide the GROUP BY clause with a column whose value is equal for all rows whose item_name you want to concatenate. Pay attention to the remark about the maximum string length returned by the function in the linked documentation.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
I'm in my last year in college and creating an application for a company is a major requirement for my diploma.
I will be using C# (MS Visual Studio) to create a transaction processing system with its own database. However, after doing some research, it seems that I'm still unable to decide which would be the better choice for the system I'm planning to create.
Some say MySQL has more advantages, some say SQL Server does a better job at handling data for businesses. I can't seem to find any consensus. I've only had experience with MS Access, and a bit with MySQL for Web programming.
To be honest, as of now I don't have a list yet of the specific requirements of the system since I will still have to meet with my advisers. It will however involve the basic functions of a common TPS: adding/deleting/editing data, viewing data, printing of reports, database management. There will be loads of data to be handled as this will be developed for business use. I am also planning to include an audit trail feature, so there's time-tracking involved.
What would you advise?
What I have tried:
After looking up several articles on the internet I still can't decide which would handle the basic needs of a TPS better. Even some of my instructors have conflicting opinions on this; some advise me to use MySQL, some advise me to use SQL Server.
I have more experience with MySQL Workbench because I've done Web programming before, and initially I was already planning to go with it for my project since I'm more familiar with it. However, a schoolmate of mine also developed such TPS, an electoral system to be precise, and he used SQL Server for it, and he recommended it to me, and with all these different opinions it's hard for me to decide.
Nothing that you have described depends on a specific database.
The question of SQL Server or MySQL therefore becomes a personal choice.
And, in this setting, that's all it is - personal choice, normally shaped by personal experience.
For the very common functionality that you describe, you will not see much advantage either way.
In a real life business situation, the scenario changes. You would probably have the resources to do large-scale performance testing for your specific scenario, and could come to a factual conclusion that way. Or, more likely, your employer would dictate which database you were to use.
But you're not in that environment. And it really does not matter. Here, it's on the same level as "Do you like blue cars or red ones?"
Code your solution in such a way that the database logic remains in the database - stored procedures, functions, etc. That way, assuming that you are connecting by way of something like Entity Framework or even ADO.net, your C# code should be talking to your database's interface - calling specific procedures or function names, rather than relying on database-specific functionality.
That way, it really does not matter which database provider you choose. So long as the entities you create within the database present themselves the same way, you can switch (for example) from SQL Server to MySQL to Oracle to Access easily.
Make your application configurable, if you like. That way, a simple change to a config file can allow your application to switch databases. You'll rarely find a real life case that calls for that, but it might get you a few more points when you hand in your assignment! Good luck!
I get the standard message:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections
Anyway, if I run an SP that basically copies a few records from one (large) table to another, it goes in a couple of seconds if I connect to the IP of the active node.
However,if I connect to the cluster IP the same SP takes three hours to run.
Why the big difference? I don't even know where to start looking, any hints are welcome.
I am doing a student attendance project in php & mysql.
I have a monthly table for recording attendance of students. the first column in the table is the roll number which is common for all the tables and the dates of each month have a column of their own.
suppose if the attendance is of 5 months, I have 5 tables of the same repeated table.
I want to create a table or view that has columns for showing total of each month with the students roll number i.e. student roll number column, first month total column, second month total column, so on.
Can anyone please help me how to do it in mysql?
Last Visit: 31-Dec-99 18:00 Last Update: 31-May-16 2:12