Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
Hello iam using sqlserver 2008.
Iam having table1 with studentid column as int.And another table table12 with same studentid column as id.Now i have to move the data from table1 to table2.Before dat i need to check whether the data in table1 is integer or not.If it is integer,i need to allow it to table2.

I have tried isnumeric(studentid),it is accepting float also like 10.0
I tried with convert(studentid,int),throwing error :cannot convert from varchar to int.


Thanks for any help
Posted
Comments
Siva Hyderabad 15-Nov-13 2:09am    
u want to copy the table1 to table2 yes?
njdcjk 15-Nov-13 2:15am    
yes,but my datatypes are different.So i need to accept only int in table 2
Siva Hyderabad 15-Nov-13 2:18am    
create procedure like this..
insert table2 select * from Table1 where sno=@Sno
njdcjk 15-Nov-13 2:24am    
Ya,in procedure only iam dng but how can i pass @sno.Is there any way to check from table1

1 solution

This question reflects one of the biggest fallacies of the beginners these days: a trend to work with strings representing data instead of data itself. If you need to have integer values in some columns, use some numeric, integer data types, not varchar. See, for example:
http://technet.microsoft.com/en-us/magazine/dd424925.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900