Tema: help : SQL CAST funkcija
Autorius: Pilas
Data: 2010-01-28 14:36:51
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876">
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT size=2 face=Arial>sveiki,</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>turiu excel lapa ir kurio reikai suimportuoti kodus 
i SQL lentele &nbsp;kaip charakterius.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>pasirasiau su&nbsp;&nbsp; CAST&nbsp;&nbsp; 
:</FONT></DIV>
<DIV><FONT size=2 face=Arial>-------------------------------------</FONT></DIV>
<DIV>
<P><FONT size=2 face=Arial>insert INTO [Baze].[dbo].[list]</FONT></P>
<P><FONT size=2 face=Arial>SELECT cast( [code] as char(20))</FONT></P>
<P><FONT size=2 face=Arial>FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',</FONT></P>
<P><FONT size=2 face=Arial>'Excel 8.0;Database=C:\SQL\baze\list.xls',</FONT></P>
<P><FONT size=2 face=Arial>'SELECT * FROM [Sheet1$]')</FONT></P>
<P><FONT size=2 face=Arial>----------------------------------------</FONT></P>
<P><FONT size=2 face=Arial>bet dalis kodu nesusiimportuoja teisingai&nbsp;: 
kodai&nbsp;6 zenklu tvarkingai gaunasi : 123456,&nbsp; o visi 7-zenkliai&nbsp; 
gaunasi kaip skaicius&nbsp;: 1.2345e+006</FONT></P></DIV>
<DIV><FONT size=2><FONT face=Arial>jei bandau trumpinti char - tada 
netelpa&nbsp; meta klaida " </FONT><FONT size=1><FONT size=2 
face=Arial>Arithmetic overflow error for type varchar, value = 
5266700.000000"&nbsp;&nbsp; cia turetu buti kodas 5266700 - 
7zenklis.</FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT size=1><FONT size=2 
face=Arial></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>cia mano SQL pradmenys, todel labai nemuskit. 
</FONT></DIV>
<DIV><FONT size=2><FONT size=1><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial></FONT></FONT></FONT>
<P>&nbsp;</P>
<P><FONT size=2 face=Arial></FONT>&nbsp;</P>
<P><FONT size=2 face=Arial></FONT>&nbsp;</P>
<P><FONT size=2 face=Arial></FONT>&nbsp;</P></DIV></BODY></HTML>