我正在尝试在 SQL Server 2008 r2 中打印表的列名。该表有一列名为chardata
。
我使用了一个select语句,
sqlQuery = "select * from information_schema.columns where table_name = 'Test'" ;
println(data = db.select(sqlQuery));
但它只是打印到屏幕 [object,object] 。 如何从此select语句中获取列名?
答案 0 :(得分:0)
如果要在表中放置名称,可以使用“AS”值结束行查询 例如:(选择T1。*)AS stude
答案 1 :(得分:0)
Javascript代码:
`> install.packages("ggmap", dependencies = T)
Installing package into ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
also installing the dependency ‘jpeg’
trying URL 'http://cran.rstudio.com/src/contrib/jpeg_0.1-8.tar.gz'
Content type 'application/x-gzip' length 18046 bytes (17 KB)
opened URL
==================================================
downloaded 17 KB
trying URL 'http://cran.rstudio.com/src/contrib/ggmap_2.5.2.tar.gz'
Content type 'application/x-gzip' length 2948233 bytes (2.8 MB)
opened URL
==================================================
downloaded 2.8 MB
* installing *source* package ‘jpeg’ ...
** package ‘jpeg’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c read.c -o read.o
In file included from read.c:1:
rjcommon.h:11:21: error: jpeglib.h: No such file or directory
rjcommon.h:29:2: error: #error "Sorry, only 8-bit libjpeg is supported"
In file included from read.c:1:
rjcommon.h:33: warning: return type defaults to ‘int’
rjcommon.h: In function ‘METHODDEF’:
rjcommon.h:33: error: expected declaration specifiers before ‘Rjpeg_error_exit’
rjcommon.h:41: error: expected declaration specifiers before ‘METHODDEF’
rjcommon.h:51: error: field ‘api’ has incomplete type
rjcommon.h:50: warning: empty declaration
rjcommon.h:59: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
rjcommon.h:75: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
In file included from read.c:3:
jcompat.h:7:20: error: jerror.h: No such file or directory
In file included from read.c:3:
jcompat.h:13: error: expected declaration specifiers before ‘METHODDEF’
jcompat.h:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘eoi_buf’
jcompat.h:15: error: expected declaration specifiers before ‘;’ token
jcompat.h:17: error: expected declaration specifiers before ‘METHODDEF’
jcompat.h:26: error: expected declaration specifiers before ‘METHODDEF’
jcompat.h:53: warning: ‘struct jpeg_decompress_struct’ declared inside parameter list
jcompat.h:53: warning: its scope is only this definition or declaration, which is probably not what you want
jcompat.h:53: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
read.c:7: warning: ‘struct jpeg_decompress_struct’ declared inside parameter list
read.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
read.c:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
rjcommon.h:32: error: old-style parameter declarations in prototyped function definition
read.c:176: error: expected ‘{’ at end of input
make: *** [read.o] Error 1
ERROR: compilation failed for package ‘jpeg’
* removing ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1/jpeg’
Warning in install.packages :
installation of package ‘jpeg’ had non-zero exit status
ERROR: dependency ‘jpeg’ is not available for package ‘ggmap’
* removing ‘/home/rk/R/x86_64-redhat-linux-gnu-library/3.1/ggmap’
Warning in install.packages :
installation of package ‘ggmap’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpnFyWnM/downloaded_packages’
`
连接到Sql Server的更好方法是使用一些服务器端语言,如PHP,Java,.NET等。客户端Javascript只能用于接口。