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
 how to check whether a passed parameter is integer

Author  Topic 

divyagr
Starting Member

29 Posts

Posted - 2009-03-24 : 06:14:36
hi all ,

i am trying to convert .net code to sql... i got strucked in between like i want to check one passed parameter is intger or not if it an interger i have to give space after that parameter... if its a varchar i have to comma after that... i tried to do this with a stored procedure .Here i am pasting the stored procedure code along this ...i have commanded where we have to check the condn which i mentioned above.... i am using sql server 2005


CREATE procedure [cus].[TEST]
(

@OrganisationName varchar(10),
@BuildingNameNumber varchar(20),
@SubBuildingNumber varchar(20),
@StreetName varchar(50),
@PostalTown varchar(20),
@Locality varchar(50)

)
as
begin
Declare @legacyaddress varchar(100)
set @legacyaddress='#'
if @OrganisationName!=NULL or @OrganisationName!=''
Begin
@OrganisationName=@OrganisationName+''
end
if @BuildingNameNumber!=NULL or @BuildingNameNumber!=''
Begin
@BuildingNameNumber= @BuildingNameNumber+''
end
if @SubBuildingNumber!=NULL or @SubBuildingNumber!=''
Begin
-- how to check "Is the BuildingNameNumber a number?"is not done
--here we have to check whether the "SubBuildingNumber " is integer or not
@SubBuildingNumber=
@SubBuildingNumber= @SubBuildingNumber+''

end
if @StreetName !=NULL or @StreetName !=''
Begin
@StreetName = @StreetName +''
end

print @legacyaddress



with regards,
Divya

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-03-24 : 06:25:29
Do you need to check for numeric or integer specifically?
Numeric:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=121492
Go to Top of Page

divyagr
Starting Member

29 Posts

Posted - 2009-03-24 : 06:42:24
thank you Darkdusky... it got resolved for me.... the link u forward to me is really worked

with regards,
Divya
Go to Top of Page

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-03-24 : 06:58:40
welcome
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-03-24 : 08:19:57
General tip:
do the validation on the frontend. Make sure the input parameters (and definitely the table columns) are the appropriate datatypes.

Be One with the Optimizer
TG
Go to Top of Page

divyagr
Starting Member

29 Posts

Posted - 2009-03-25 : 00:33:17
k TG I will try like that....Thank you

with regards,
Divya
Go to Top of Page
   

- Advertisement -