我在Query Analyzer中运行这样的语句行不通, 如下: declare @strsql char(500)select @strsql='create table #temp'select @strsql=rtrim(@strsql)+'(bookid,name)' 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 declare @strsql char(500)declare @tmpsql char(500)select @strsql = 'create table #temp'select @tmpsql = '(bookid,name)'select @strsql=rtrim(@strsql) + @tmpsqlprint @tmpsqlprint @strsql由于你定义的字符串长度为500,不足500的自动加空格,所以@strsql加了'(bookid,name)'后中间有许多空格,而超过500个字符自动删除500以后的字符 declare @strsql varchar(500) --改用varcharselect @strsql='create table #temp'select @strsql=@strsql+'(bookid,name)' declare @strsql varchar(500)select @strsql='create table #temp'select @strsql=@strsql+'(bookid,name)'select @strsql很简单吧,是不是和你的想法一样了? 方法一:declare @strsql char(500)select @strsql='create table #temp'select @strsql=rtrim(@strsql)+'(bookid,name)'方法二:declare @strsql varchar(500)select @strsql='create table #temp'select @strsql=@strsql+'(bookid,name)'select @strsql 关于SQL的问题。。。 急!~关于update的问题 请教一group by 问题,谢谢 asp+sql 多表间的分页存储过程如何实现? sql server 2000附加数据库失败 update sysprocesses sql server 2000里面datetime一天也是1么? 一个比较困惑的问题 一个sybase的问题 轮询问题 SQL SERVER的中文编码问题 请问在MS SQL SERVER 7 中Query Analyzer怎样实现这样的功能:先对变量strsql赋值,
declare @tmpsql char(500)
select @strsql = 'create table #temp'
select @tmpsql = '(bookid,name)'
select @strsql=rtrim(@strsql) + @tmpsql
print @tmpsql
print @strsql
由于你定义的字符串长度为500,不足500的自动加空格,所以@strsql加了'(bookid,name)'
后中间有许多空格,而超过500个字符自动删除500以后的字符
select @strsql='create table #temp'
select @strsql=@strsql+'(bookid,name)'
select @strsql='create table #temp'
select @strsql=@strsql+'(bookid,name)'
select @strsql很简单吧,是不是和你的想法一样了?
declare @strsql char(500)
select @strsql='create table #temp'
select @strsql=rtrim(@strsql)+'(bookid,name)'
方法二:
declare @strsql varchar(500)
select @strsql='create table #temp'
select @strsql=@strsql+'(bookid,name)'
select @strsql