i have a column its values must started with 1 and incrementing by 1
this column repeatly looses his rows
so i can not use identity here
so i tried to raise a trigger to do the job
but i have some probelems with the following statments
create trigger dbo.insertNum
on testIcreTrigger --table name
declare @insVal int --value to insert
declare @MaxVal int
select @MaxVal= Max(Num) from hitTheatre
insert into testIcreTrigger (Num)
Can i install sqlserver2000 and 2005 in same folder.
I have already installed sqlserver2000 in my XP,and i want to install sqlserver2005.
I dont if it raises any problem or not,if not,wat kind of things i have to consider.
Give me some answer.
can i install in different folders.my sqlserver2000 and vs2003 are installed in C:/
and vs2005 in D:/,now where i have to install my sqlserver2005.
I am not sure whether SQLServer 2000 and SQLServer 2005 can be installed in same folder. But they can be installed on same machine in different folders. However, you can not have two default instances of any version of SQL Server but you can have ten different installations of SQLServer 2000 and SQLServer 2005 as long as they are all named differently, they can co-exist with out an issue.
Am creating a small Projects using Vb.Net and Sql server 2005, in that i want to get a input automatically for one column(Eno column), that column is a alphanumeric column, i want to store information automatically like below,
if the Employeename is 'Anton' it will automatically fill the Eno as A001, if Employeename is 'Brail' then it will fill 'Boo1' if again Employeename is 'Berg' then 'b002' and so on. can i get that by adding a trigger or stored Procedure, if so then tell simply code examle for this, this very urgent for me, so Pleeeeeeeeeeeeease help me.
I am going to assume you are trying to create a key field for your employee, if so then:
DO NOT ADD INTELLIGENCE TO A PRIMARY ID/KEY FIELD, you are doing this by adding the first character of the surname. This is wrong, it should simply be the record identifier, use the surname field for search/sorting NOT the ID field.
Generating an employee number for human consumption (timecards or something) is a different matter. I would put it in the inserting stored procedure (I never use triggers)
Before the insert get the count of existing surnames with the 1st char
Select @N = (count(*) + 1) From Employee where Surname like 'A%' (this fails when the employee changes surnames - gets married and is the reason for the initial comment)
Select top 1 employee where ENO like 'A%'
order by ENO desc
Add the text to the ENO field
Never underestimate the power of human stupidity
Below Code generates Error in if, Please let me know whats wrong in this
create procedure refno_stock
declare @stockrefno as varchar(50),
@category as varchar(50)
if @category = 'Desktop'
select ( count(*)+1) as Stockrefno from stockmaster where category like'd%';
if @category = 'Laptop'
select ( count(*)+1) as Stockrefno from stockmaster where category like'L%';
if @category = 'HDD'
select ( count(*)+1) as Stockrefno from stockmaster where category like'H%';
This is not a "trigger" or an procedure operation. You would need to create and schedule a job in SQL Server to acheive this. It would have to poll the target table to identify the records inserted say every 2 minutes and if there are records then execute the mailing stored proc.
Never underestimate the power of human stupidity
Hi, I'm still a beginner in this. Creating code in vb to log in a user. The username and password typed into the textbox must be verified against the username and password in the database. I use a SqldataReader to perform this action but can't seem to get the syntax correct... please can you help me.
Here is the Function and the relevant button :
Protected Sub butLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butLogin.Click
If CheckPassword(txtusername.Text, txtpassword.Text) Then
MsgBox("username or password not found. try again")
Private Function CheckPassword(ByVal username As String, ByVal password As String) As Boolean
Dim bsuccess As Boolean
Dim command As New SqlCommand("SELECT (Username,Password) from UserInfo WHERE Username = '" & txtusername.Text & "'", connection)
Dim drdUsers As SqlDataReader
drdUsers = command.ExecuteReader
If txtpassword.Text = drdUsers.Item("Password") Then bsuccess = True
bsuccess = False
Secondly your Code is messy, it seems you dont know where to put your code. You are Executing the command outside your connection. Open the Connection and Execute your command and Close the Connection and Close the reader and after that you dont need to loop through the reader. Here is my Suggestion, why dont you use a StoredProcedure that returns number of rows ,and when you call that Stored Procedure you will test for records that are returned. if you planned it well you will be looking for an integer that is "1" or less than one , e.g
if(intTeturned < 1)
//Valid Login , then you can redirect your users to the page you want.
Hope this Helps
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
I created a kind of employees application with all sorts of data. I working with SQL server and C#.
I have most string and int data, but also some images.
But i use the "string-with-path-method" to get to the images.
It works ok, but since the images are in a folder, it seems that they are not as private like the other data.
I dont know how to work with the images in SQL server, so i use that method.