|
Hi all,
First let me discuss the scenario. I have 2 tables,a party master table where in i store all details of party(a user) which has a PK partycode and a price_relation_master table where i associate that party with multiple items ie an itemcode.The items come from a table called item_master with pk itemcode where all the details of an item are stored.
Now i wan`t to develop a copy facility such that all the items assigned to a party are copied to other party. Copying is not a prob, but i before copying i have to check whether that item was previously assigned to dest party or not. If the item was assigned to that party that item shouldn`t be copied. Does any body have any info about such cases!!!! Any help would be appreciable....
When you fail to plan, you are planning to fail.
|
|
|
|
|
How to pass the parameters of @dbName, @LogicalName, @ToServer
to job dynamically using stored procedure?
|
|
|
|
|
I am having trouble figuring how to structure the tables to solve this problem. Here's where i'm at:
Existing Tables:
Tool(
ToolID Int Id PK...,
...,
Cavities Int Not Null
)
Product(
ProdID Int Id PK...,
...
)
ProdLine(
PLine ID Int Id PK...,
...
)
Problem:
A Production 'Cycle' consists on making a combination of 1 to n Products with a specific Tool where n <= Cavities for that Tool.
For example, a tool can make up to n peices of 1 product per cycle, or 1 peice of 4 products per cycle, or a combination thereof.
A common combination would be for two products to be made with a given tool on a given ProdLine in a given amount of time.
I want to create table(s) to reflect the relationships between this additional data(CycleTime, and Product Combinations for a Tool) and the existing tables.
hope this is decipherable, it is spinning my head.
Is have modelled several solutions that are all very ugly and I wonder if anyone has an elegant suggestion (...my wife has given me many (non-elegant) suggestions mostly regarding why i am trying to learn this concept on Easter Friday night! )
|
|
|
|
|
Hi,
How to Debug stored porcedure SQL server 2000 ?
Thank& Regards
Vijay s
|
|
|
|
|
Hi Vijay,
If you are looking to debug a stored procedure within SQL Server 2000 then I would like to mention that it consits several steps which is hard to explain here. Thefore, I would suggest you go through the following article which explains debugging process (within SQL Server 2000) step by step.
http://www.15seconds.com/issue/050106.htm[^]
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
if you want to debug the stored procedure, open a stored procedure and right click and select the option 'step into stored procedure', you can debug stored procedure without debugging your application.
|
|
|
|
|
I would like to create two procedures that do the following:
1. Retrieving the next value that an identity column would get if a new row is inserted.
2. Change the value of the next value that will be created when the next row is inserted.
Can I do any of the above with C# and ADO.NET?
(Using SQL Server 2005)
_____________________________
...and justice for all
APe
|
|
|
|
|
d00_ape wrote: Retrieving the next value that an identity column would get if a new row is inserted.
IDENT_CURRENT + 1[^] gives the next identity value for specified table.
d00_ape wrote: Change the value of the next value that will be created when the next row is inserted.
Set IDENTITY_INSERT[^] to "on" for inserting into an identity column.
|
|
|
|
|
1. OK - IDNTITY_CURRENT + 1 works perfect for me!
2. I don't know if I missunderstand but can really helpe me to modify what the next identity number will be? I dont want to manually do INSERTs with the identity column value, only step the counter forward to a specific value.
----------------------------------------------------------------
My goal is to make users of a program (that uses the db and the table) to set a new start value each year.
Year 2008: next new row id = 200800001
Year 2008: next new row id = 200900001
I use the id to represent an Invoice-number and my clients like to see on the number from which year it is created.
_____________________________
...and justice for all
APe
|
|
|
|
|
d00_ape wrote: modify what the next identity number will be
Ok, I misunderstood you. If you need to change the next identity value, reseed it. Try DBCC CHECKIDENT (table, reseed, value)
|
|
|
|
|
Perfect!! That's what I needed!
_____________________________
...and justice for all
APe
|
|
|
|
|
you can do this using two methods.
1) using sql server column identity property:
in this method, which column you want to give identity, open the table definition and right click on the field (which you want to be indent), set the identity specification - IsIdentity to 'yes' & Identity Increment and Identity seed to 1.
2) using c# in your asp.net page:
using asp.net page, first get the maximum record of the table using max(column name) using data reader & increment that value to 1 and assign that value to new inserted row.
for ex:
sqlconnection cn = new sqlconnection();
cn.open();
string str = "select max(userid) from user";
sqlcommand cmd = new sqlcommmand(str,cn);
idatareader rdr = cmd.executereader();
int id = 0;
if(rdr.read()==true)
{
id = rdr[0].tostring();
}
id = id+1;
now the id you will get is incremented id for inserting new query or row to table.
use this id and insert value of this id as the field of userid to insert new row.
|
|
|
|
|
Hi,
I need help with an sql query please.
I wish to insert a new record into a table, and instantly retreive the new records id. Is it possible to do this in one sql statement rather than an INSERT followed by the SELECT statement?
My INSERT looks like this:
<code>string conn = System.Configuration.ConfigurationManager.ConnectionStrings["artisanConnectionString"].ConnectionString;
SqlConnection uniqueCon = new SqlConnection(conn);
//set SQL statement
SqlCommand cmd = new SqlCommand("INSERT INTO [tbl_Additional] (add_Item, add_Price) VALUES ('" + TextBox10.Text + "', '" + TextBox11.Text + "') ", uniqueCon);
cmd.Connection.Open();
try
{//insert/ add new record
//commit to database
cmd.ExecuteNonQuery();
//clear form add/edit
TextBox10.Text = null;
TextBox11.Text = null;
//confirm to user
ShowMessageBox("New unique Item Added!");
//update dataset
GridView2.DataBind();
}
catch
{
ShowMessageBox("Unable to add record!!! Please try again later.");
}
cmd.Connection.Close();</code>
Any help would be greatly appreciated.
Thanks & Happy Easter!
|
|
|
|
|
You should use a stored procedure, then you can populate an OUTPUT parameter with SCOPE_IDENTITY() value, example: here[^].
|
|
|
|
|
Hi,
Any one suggest me how to write a sql query to execute the following.
I am having three tables as show below:
Table 1:
EmpID Name
1 aaa
2 bbb
3 ccc
Table 2:
SalID EmpID DesigID Salary
1 1 000000 000000
2 3 000000 000000
Table 3:
DesigID SalID DesigID Left
1 1 000000 false
2 2 000000 True
In the above i have to get the SalID,Salary details, based on the below condition
1. Based on the EmpId
2. The DesigID from table 3 should be retireved, but that DesigID should not be presented in Table 2(only those rows not presented in table 2 should be retrieved from table 3) based on the DesigID in both tables, also with one more condition.
3.Also i have to retrieve the rows from table 3 if the boolean value is true based on the SalID.
Am i clear with the above process? If no please kindly excuse me.
Any one please suggest me
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
how to get columns of table in order of their ordinal position instead of
alphabetical order of column name?
cn.GetSchema("Columns", restrictions)
output: column_name ordinal_position
...........ambit...............3
...........noise...............1
...........z...................2
required output: column_name ordinal_position
....................noise...............1
....................z...................2
....................ambit...............3
|
|
|
|
|
I want the columns of table in order of their ordinal position.
is it possible?
|
|
|
|
|
exec sp_columns '[table name]'
If that's too much info then you could try:
SQL 2000
SELECT o.name, c.name as columnname FROM syscolumns c
INNER JOIN sysobjects o ON o.id = c.id
WHERE o.[name] = 'reports'
ORDER BY c.colorder
SQL 2005
SELECT O.name, C.name as columnname FROM sys.columns C
INNER JOIN sys.objects O ON O.object_id = C.object_id
WHERE O.[name] = 'reports'
ORDER BY c.column_id
|
|
|
|
|
Thank You Mark. It Works. Well Done.
|
|
|
|
|
i m planning to create a job site,so plz guide me for design the database,tables in sqlserver 2005
|
|
|
|
|
If you can't design the tables are you sure you are competent enough to create a complete web site?
Try reading up on the subject rather than asking someone to do your work for you.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
AbhishekAgarwal15 wrote: so plz guide me for design the database,tables in sqlserver 2005
Well - I'd start by gathering requirements, working out what fields need to be in the database and then normalize it to at least third normal form. Here's a technical hint for you - consider investing in some paper and pencils for your design.
|
|
|
|
|
You need to do alot of planning, investigation and searching (on the web). If you don't know how to design the database and tables I agree with the other person find out for yourself. You'll get alot more satisfaction if you've done the work yourself. Trust me I know!
Kris MCP
|
|
|
|
|
Hi All,
I wanted to go for the OCP. Can any one please let me know How many exams I have to give? Which are the exams and the fees structure? And from where I can give this exam and how to pay the fees of the exams. I wanted to do OCP in 9i or 11i.
Thanks,
RK
|
|
|
|
|
Have you tried looking on the Oracle web site? I bet they have loads of information about OCP
Bob
Ashfield Consultants Ltd
|
|
|
|