Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Inset data

Author  Topic 

velliraj
Yak Posting Veteran

59 Posts

Posted - 2010-06-28 : 14:56:12
Hi Please help me out on this requirement
1. we have scripts written already contains select statements
2. we have to identify the error vaues being fetched from the select statements (whether numeric or not)
3. these error values aling with id we have to insert into error log table.

please help me out or any logic how to fix. This is really appreciable.

X002548
Not Just a Number

15586 Posts

Posted - 2010-06-28 : 15:03:40
gonna post the SELECT statements?

Sounds like an assignment



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

velliraj
Yak Posting Veteran

59 Posts

Posted - 2010-06-28 : 23:40:48
any help even its assignment
Go to Top of Page

velliraj
Yak Posting Veteran

59 Posts

Posted - 2010-06-29 : 02:13:35
ALTER PROCEDURE SpValid1

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @t table(ID int identity, EmpID int)

INSERT INTO @t
Select empid from dbo.employee
where empname = ''
DECLARE @TotCount int
SELECT @TotCount = COUNT(empid) from employee
--select @TotCount

Declare @empID int
Declare @empName varchar(50)
Declare @i int
Declare @curEmpID int
declare @dob datetime
set @i = 1
print @empname
while @i < @TotCount
Begin
print @i
select @curEmpID = EmpID from @t where [ID] = @i
--select * from @t
Select @empID = empID, @empName = empname, @dob = dob from employee
where empID = @curEmpID

IF @empName is null --or @bob is null
Begin
Insert into employeex values(@empName)
End
IF @dob IS NULL --or @bob is null
Begin
Insert into employeex values(@dob)
End

Print CAST(@empID as varchar)+ ' '+ @empName
set @i = @i + 1
End

END
GO
Go to Top of Page

p_agganesh
Starting Member

1 Post

Posted - 2010-06-29 : 02:16:57
ALTER PROCEDURE SpValid1

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @t table(ID int identity, EmpID int)

INSERT INTO @t
Select empid from dbo.employee

DECLARE @TotCount int
SELECT @TotCount = COUNT(empid) from employee
--select @TotCount

Declare @empID int
Declare @empName varchar(50)
Declare @i int
Declare @curEmpID int
declare @dob datetime
set @i = 1
print @empname
while @i < @TotCount
Begin
print @i
select @curEmpID = EmpID from @t where [ID] = @i
--select * from @t
Select @empID = empID, @empName = empname, @dob = dob from employee
where empID = @curEmpID

IF @empName is null or @empname =''
Begin
Insert into employeex values(@empName)
End
IF @dob IS NULL --or @bob is null
Begin
Insert into employeex values(@dob)
End

Print CAST(@empID as varchar)+ ' '+ @empName
set @i = @i + 1
End

END
Go to Top of Page
   

- Advertisement -