|
Thx for the reply, my requirement is i need to add '*' to the column, pls go through the query once, if you find time.
|
|
|
|
|
Sorry i need to convert Int to varchar to add * or flag it, to identify that is exist in another table.
thanks heaps..
|
|
|
|
|
I use "INSERT INTO [Flash Turn Parameters] " +
"VALUES ('" + toolPosition1.ToS .....
to create a new record in a database table
and use cmd.ExecuteNonQuery(); to execute the SQL from C# ADO
the 1st field is an auto increment IDENTITY field. How can I find out the value after the record has been created ?
Thanks
|
|
|
|
|
use a stored proc like this:
create proc Insert @value int
declare @id int
insert into [bad table name] values (@value)
set @id = scope_identity()
return @id
You could also make it an out parameter
create proc Insert @value int, @id int out
insert into [bad table name] values (@value)
set @id = scope_identity()
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You need to write a stored procedure that performs the INSERT operation and then returns the latest IDENTITY value as an OUTPUT parameter. The latest IDENTITY value can be determined by using the SCOPE_IDENTITY[^] command.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hello everyone,
how can i create an updatable view in sql server 2005.
Thanks.
|
|
|
|
|
I suggest you read this article[^].
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hello,
i have to develop an application to compare a dataset (with around 1000s of records)with a database table which has almost more than 4 million records.
and if the dataset has matches in the table i will mark them as processed. is there any way to achive this .
note: i already have tried comparing them with 2 loops iterating manually in each record...i want some other way
aneef
|
|
|
|
|
Assuming you are using SQL Server, a possible solution would be:
1. Serialize the contents of your dataset as XML and submit the data to your database using a stored procedure and the OPENXML command.
2. In your stored procedure, load the serialized data into a table variable whose structure matches the dataset. Add an extra bit field called Processed that can be used to mark matched records.
3. Run an UPDATE query on your table variable, joining it to your master database table. Set the value of your Processed field in the matching records to 1.
4. From your stored procedure, return all records in the table variable where Processed = 1.
Hope this helps.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I want to know what are the naming conventions for creating the above mentioned? I went through some of the adventure works tables and looking at the indexes they either start with IX or AK, for example:
IX_EmployeeDepartmentHistory_DepartmentID
Please advise.
Brendan
|
|
|
|
|
Hi,
I have 3 tables, namely:
CategoryGroup
CategoriesInCategoryGroup
Categorty
CategoriesInCategoryGroup has only 2 fields, which I made the primary key each, namely CategoryGroupId and CategortyId, and they each reference the corresponding table. So basically they are foreign keys.
I have a question when creating an index in the CategoriesInCategoryGroup table. Do I create 1 index, or should I create a separate index for CategoryGroupId and CategortyId in the CategoriesInCategoryGroup table?
Please advise.
Brendan
|
|
|
|
|
Is always a good idea to create an index for each field (or group of fields) that forms a FK
Only in few cases you could not create such an index, i.e. when it is the first field in an already existing index or is equal to de PK.
Habetis bona deum
|
|
|
|
|
Hi Brendan
I would expect CategoriesInCategoryGroup to have CategoryGroupId and CategortyId as a clustered primary key. You would then normally create a separate non-clustered index on the CategoryId column.
If you are not using SQL-Server then the second index should be combine CategortyId and CategoryGroupId.
Regards
Andy
|
|
|
|
|
OK, I realise this is generally a SQL server-oriented forum, but I'm a bit stumped so I'll post anyway.
I was debugging an Oracle package which does a massive number of updates (9,6000,000 approx.) and it hung. I tried to kill the process but that didn't work either, and I had to kill TOAD eventually. When I went back in, I found that Oracle had placed a lock on the package, so I can't compile, change, or even drop the object. Does anyone know where I need to go in Oracle to release this lock? I don't have a DBA on-site here, I'm pretty much on my own.
Smokie, this is not 'Nam. This is bowling. There are rules.
|
|
|
|
|
Hi,
if we are trying to add the several columns in select statement without using Aggregate functions and only one condition in group by.
how can we do that ??
|
|
|
|
|
I'm not sure I understand you. Can you throw some SQL my way...
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
praveenanand wrote: if we are trying to add the several columns in select statement without using Aggregate functions and only one condition in group by.
You can't. Each column not specified in the GROUP BY clause must be part of an aggregate on the SELECT. If you think about what it is doing you will see why.
|
|
|
|
|
Hello,
I'm working on a project and its deadline is comming really close. I have a State and cities Table to store the names of the states and cities of the US. I've populated the State Table manually but the cities is like quite a hectic task. Is there some way that I can load the names of teh cities programaticaly (thru a file or something) in to the db
I'm using SQL 2005 and .NET 2.0
Any suggestions, guidlines are welcome
Thanks in advance
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
When I needed to load a list of all the countries in the world I used an XMLDataSource and found an XML file with all the countries in it. I think I found the file at the US Census Bureau web site if I'm not mistaken.
I'm sure you could find an XML list with all the cities and then you could load it and save it to the db.
And how do you manage to submit a post on the 13th of December? Pretty crazy.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
ok that's gr8 I'll chk it out to see what I can find on google.
Rohde wrote: And how do you manage to submit a post on the 13th of December? Pretty crazy.
That one was over the top Sir!! Didnt get it????
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
Rocky# wrote: That one was over the top Sir!! Didnt get it????
Heh
When I reply to your post the beloved CP displays:
Reply to Message header: Forum: SQL / ADO / ADO.NET
Subject: Re: Is there a way to efficiently load the cities of US into the database
Sender: Rocky#
Date: Thursday, December 13, 2007 2:24:00 AM
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
oh wow! that mean ATTN CP web masters!! There's a little issue around here. I wonder where did that come from
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
I have a problem in selecting one row of a table
1. Could you help me to select only one row without querying by the data inside the table, please ?
2. How i can identify the row ?
thanks and regards,
azumike
|
|
|
|
|
You use a primary key.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
thanks for your inquiry,I have it, but, i want to select row without key on the table,
i mean that i want to select 1st row, 2nd row etc.
example i have table:
table name is: "person"
No | property
----------------------
1 | house
1 | name
1 | age
i want to select 2nd row but i don't wanna use :
select * from person
where property='name'
any other way ?
regards,
azumike
|
|
|
|