Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DONT INSERT ZEROS

Status
Not open for further replies.

100dtl

Programmer
Aug 18, 2003
313
GB
Hi all,

I have a default row value is 0 so I dont need any more zero's, how do i alter this code so i dont add zero's

-- does the COORD x exist?
Set @cmd = 'insert into CARRSITE.dbo.temp ([ID]) (Select [Id] from CARRSITE.DBO.GERMNFR_COORD where [name]=' + cast(@x AS VarChar) + ')'
exec(@cmd)

select @eId=id from CARRSITE.dbo.temp
If @eId = 0
Begin
INSERT INTO CARRSITE.DBO.GERMNFR_COORD (NAME) VALUES (@x)
Set @eId=@@IDENTITY
End
if @columns is null
Begin
Set @columns = 'eID'
Set @values = cast(@eId AS varchar)
Set @where = 'eID=' + cast(@eId AS varchar)
End
else
Begin
Set @columns = @columns + ',eID'
Set @values = @values + ',' + cast(@eid AS varchar)
Set @where = @where + ' AND eID=' + cast(@eid AS varchar)
End
 
Not sure but i think I've sussed it..

temp tables complicating matters

Set @eId=0
Select @eId=Id from carrsite.dbo.germnfr_coord where name=@x
If @eId = 0
Begin
INSERT INTO CARRSITE.DBO.GERMNFR_COORD (NAME) VALUES (@x)
Set @eId=@@IDENTITY
End
if @columns is null
Begin
Set @columns = 'eID'
Set @values = cast(@eId AS varchar)
Set @where = 'eID=' + cast(@eId AS varchar)
End
else
Begin
Set @columns = @columns + ',eID'
Set @values = @values + ',' + cast(@eid AS varchar)
Set @where = @where + ' AND eID=' + cast(@eid AS varchar)
End
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top