|
Hi,
I have a members table, and the primary key ID is of type int, which has been setup to automatically increment the ID by 1 when a new member has been entered. I have added a lot of members while testing, but when I go live with the site then I would like to reset the auto-incrementer so that when a new member is added it starts back at 1 again. How do I do this?
I hope someone can help!!
Regards,
ma se
|
|
|
|
|
dbcc checkident('table_name'reseed,0)
|
|
|
|
|
Thanks, but where do I type this in? SQL Management studio? Where can I read more about this?
|
|
|
|
|
Open Query analizer use ur Databse and write taht line code
dbcc checkident('table_name',reseed,0) and run this query
check this also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_dbcc_5lv8.asp
--run this query
use name_of_dataabse
dbcc checkident('table_name',reseed,0)
|
|
|
|
|
Hi all..
Please help me make SQL server, send alerts with special text, as SMS or email to a specified person whose phone or email are present in the database.The sending process should occur when the data related to this person is updated, or when his birthday is met for example(as a reminder).
And how can SQL launch an application, for example vb.net or asp.net application as a responce for an event, alert, or job.
AND Thanks before...
Sirag..
|
|
|
|
|
Have you looked at SQL mail? There is a COTS package called Postie that will send mail too. SQL mail requires Outlook to be installed on the SQL Server. Check also DatabaseMail with SQL 2005
|
|
|
|
|
Im developing in Visual Studio 2005 and trying to insert the value of a Radio Button into a specific row of a SQL Table.
Is there a "codeless" way to do this ????
Thanx ¡
Armando
---
Mexico
|
|
|
|
|
PLESE RE_POST IN PROPER AREA. THAT IS NOT A SQL QUESTION
|
|
|
|
|
I am developing a system using Dreamweaver ASP.NET VB, with MS SQL server. I need to know how to insert signature in database (store) and make it appear at a page that comes with the person's name, position and etc for user's view. each page for one person's particular.
|
|
|
|
|
Hello,
I have an identity column that is set up to auto-increment via the "Identity Increment" property for the column. This is working fine.
However, I have another column that I'm calling "Sequence". This is not an identity column, it just specifies the position of each record which is subject to change. I want to set up the column to auto-increment so I don't have to manually enter the Sequence number for each record I add. Is there a way to set up a column to auto-increment without making the column an Identity column, and still allowing me to manually change the Sequence numbers later if I want?
BTW: I'm adding data to the table in Microsoft SQL Server Management Studio.
Thanks!
Ian
|
|
|
|
|
Use follwing:
objCol.AutoIncrement = true;
objCol.AutoIncrementSeed = 1;
objCol.AutoIncrementStep = 1;
objCol.ColumnName = "ID";
|
|
|
|
|
Thanks for the reply. I should have specified that I'm creating the table in Microsoft SQL Server Management Studio. These column properties don't seem to be exposed in the table designer. At least I can't find them...
Ian
|
|
|
|
|
You caqn not have more that one identity column per table. The way to handle what you are attempting may be to insert the new record, get the identity using the SCOPE_IDENTITY() function then updating the record with that value
|
|
|
|
|
If I have 2 INSERT statements in my stored procedure, one to add a member to the member table, and one to add the member's role to the MemberInRoles tables.
Let say the second INSERT fails, and I do a ROLLBACK TRANSACTION, will it remove the row added in the first INSERT statement?
How far does ROLLBACK TRANSACTION go? Will it reverse everything?
|
|
|
|
|
ma se wrote: will it remove the row added in the first INSERT statement?
It depends where you put the BEGIN TRANSACTION
ma se wrote: How far does ROLLBACK TRANSACTION go?
Back to where you put BEGIN TRANSACTION .
ma se wrote: Will it reverse everything?
It will reverse everything on that connection to the point that BEGIN TRANSACTION was called. Other users of the database are unaffected (unless they are reading uncommitted changes [aka dirty read]- in which case they are declaring they realise some of the changes they are reading may not be valid)
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Ok thanks!!
When I do a COMMIT TRANSACTION, do I need to do it for both INSERTS, or does using it once commit both INSERTS?
|
|
|
|
|
ma se wrote: When I do a COMMIT TRANSACTION, do I need to do it for both INSERTS, or does using it once commit both INSERTS?
The COMMIT TRANSACTION will commit all changes since the BEGIN TRANSACTION . So, do it once after both inserts.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Hey Colin!!
Thanks for all the information, it is greatly appreciated!!
So how long have you been in databases? You probably know everything there is to know on SQL Server. Hows it going with SQL Server 2005? Do you do any other databases?
Cheers.
|
|
|
|
|
ma se wrote: So how long have you been in databases?
Commercially? About 12 years.
ma se wrote: Hows it going with SQL Server 2005?
I've played with it a little, but I've not had a chance to work with it yet.
ma se wrote: Do you do any other databases?
To the same level as SQL Server? No. But I do know various other databases, but since I've been using SQL Server almost exclusively for the last 3 years it would take a wee while to pick some of it up again. However, most databases I've used have some varient of SQL so it isn't that hard to go from one to another.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
I have another question.
I have a stored procedure that inserts the member, and a stored procedure that inserts a roles for that member. So when the member is added successfully, then it calls the other stored procedure passing it the parameters of memberID and roleID.
Now comming back to the COMMIT TRANSACTION and ROLLBACK TRANSACTION. If a ROLLBACK TRANSACTION is done now after this call, will it go and remove that record as well (which was inserted from the call to the "outside" stored procedure)?
|
|
|
|
|
i think Colin is the best one to answer SQL questions over CodeProject, but i can give it a try
transactions can be seen for what you write on the database as an atomic statement. this means that when you begin a transaction, everything you write inside the transaction is actually buffered. when you commit the transaction, the database is physically altered by writing you datas. if you rollback the transaction, everything you did inside the transaction is lost, and the database state (as it was before your transaction) is not modified.
|
|
|
|
|
hi guys
i have question in SQL
select * from user where id='aaa' and pass='hello';
the problem is who can i make it case sensitive
like if in my table AAA exist it's different then aaa how can i select
the exacte word
Regards,
Charbel
|
|
|
|
|
hi,
First of all if your user table has an identity column PK so you can get the data by The PK.
Second here is a function that may come in handy
//For small a at the begining
Select * from user<br />
Where ASCII( id ) = 97
//for Big a at the begining
Select * from user<br />
Where ASCII (id ) = 65
ASCII Function:
Returns the ASCII code value of the leftmost character of a character expression.
|
|
|
|
|
Cast them to varbinary:
SELECT
*
FROM
user
WHERE
CAST(id AS VARBINARY(50)) = CAST('aaa' AS VARBINARY(50)) AND
CAST(pass AS VARBINARY(50)) = CAST('hello' AS VARBINARY(50))
|
|
|
|
|
Not an issue unless the database is set to be case sensitive. Other wise you can do this
select *
from user
where UPPER(id) = UPPER('aaa')
and UPPER(pass)= UPPER('hello');
|
|
|
|