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.
| Author |
Topic |
|
velliraj
Yak Posting Veteran
59 Posts |
Posted - 2010-06-28 : 14:56:12
|
| Hi Please help me out on this requirement1. we have scripts written already contains select statements2. 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 |
|
|
velliraj
Yak Posting Veteran
59 Posts |
Posted - 2010-06-28 : 23:40:48
|
any help even its assignment |
 |
|
|
velliraj
Yak Posting Veteran
59 Posts |
Posted - 2010-06-29 : 02:13:35
|
| ALTER PROCEDURE SpValid1ASBEGIN-- 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 @tSelect empid from dbo.employeewhere empname = '' DECLARE @TotCount intSELECT @TotCount = COUNT(empid) from employee--select @TotCountDeclare @empID intDeclare @empName varchar(50)Declare @i intDeclare @curEmpID intdeclare @dob datetimeset @i = 1print @empnamewhile @i < @TotCountBeginprint @iselect @curEmpID = EmpID from @t where [ID] = @i--select * from @tSelect @empID = empID, @empName = empname, @dob = dob from employeewhere empID = @curEmpIDIF @empName is null --or @bob is nullBeginInsert into employeex values(@empName)EndIF @dob IS NULL --or @bob is nullBeginInsert into employeex values(@dob)EndPrint CAST(@empID as varchar)+ ' '+ @empNameset @i = @i + 1EndENDGO |
 |
|
|
p_agganesh
Starting Member
1 Post |
Posted - 2010-06-29 : 02:16:57
|
| ALTER PROCEDURE SpValid1ASBEGIN-- 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 @tSelect empid from dbo.employeeDECLARE @TotCount intSELECT @TotCount = COUNT(empid) from employee--select @TotCountDeclare @empID intDeclare @empName varchar(50)Declare @i intDeclare @curEmpID intdeclare @dob datetimeset @i = 1print @empnamewhile @i < @TotCountBeginprint @iselect @curEmpID = EmpID from @t where [ID] = @i--select * from @tSelect @empID = empID, @empName = empname, @dob = dob from employeewhere empID = @curEmpIDIF @empName is null or @empname =''BeginInsert into employeex values(@empName)EndIF @dob IS NULL --or @bob is nullBeginInsert into employeex values(@dob)EndPrint CAST(@empID as varchar)+ ' '+ @empNameset @i = @i + 1EndEND |
 |
|
|
|
|
|