sql的rpt文件,怎么变成.sql文件或者一张表也行,一句话,我想要它的数据在表里面

吴青峰 2010-11-23 02:49:05
sql的rpt文件,怎么变成.sql文件或者一张表也行,一句话,我想要它的数据在表里面
...全文
159 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
WJY258378040 2010-12-02
  • 打赏
  • 举报
回复
像楼主这样的人品肯定不会给分!

整一个不懂装懂的!自以为是的....无知的小人
吴青峰 2010-11-24
  • 打赏
  • 举报
回复
你们都理解错了,我的意思是想把表的数据导出成sql文件,然后下次我用的时候,就用sql的文件直接生成表的数据就可以用了。我之前有过,城市、省份的这些表的sql文件,但是现在找不到了。所以我想把现有的表导成sql,方便我下次使用。
吴青峰 2010-11-24
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 dawugui 的回复:]
引用 8 楼 qingfeng_wu 的回复:
看到的内容不是我想要的
我主要是想把这些内容放到表里面!

你的文件是什么内容?其格式是怎样的?是单独一整个文件存放在表里面吗?
如果是,需要使用image,text等字段来存放了。

SQL code
ntext、text 和 image
用于存储大型非 Unicode 字符、Unicode 字符及二进制数据的固定长度和可变长度数……
[/Quote]
不是,我的是有表导出成rpt文件,现在有想把这个文件的数据导入表中,它里面的数据格式和我表里面的数据格式完全一样。
dawugui 2010-11-23
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 qingfeng_wu 的回复:]
看到的内容不是我想要的
我主要是想把这些内容放到表里面!
[/Quote]
你的文件是什么内容?其格式是怎样的?是单独一整个文件存放在表里面吗?
如果是,需要使用image,text等字段来存放了。
ntext、text 和 image
用于存储大型非 Unicode 字符、Unicode 字符及二进制数据的固定长度和可变长度数据类型。Unicode 数据使用 UNICODE UCS-2 字符集。

ntext

可变长度 Unicode 数据的最大长度为 230 - 1 (1,073,741,823) 个字符。存储大小是所输入字符个数的两倍(以字节为单位)。ntext 在 SQL-92 中的同义词是 national text。

text

服务器代码页中的可变长度非 Unicode 数据的最大长度为 231-1 (2,147,483,647) 个字符。当服务器代码页使用双字节字符时,存储量仍是 2,147,483,647 字节。存储大小可能小于 2,147,483,647 字节(取决于字符串)。

image

可变长度二进制数据介于 0 与 231-1 (2,147,483,647) 字节之间。

注释
下面的函数和语句可以与 ntext、text 或 image 数据一起使用。

函数 语句
DATALENGTH READTEXT
PATINDEX SET TEXTSIZE
SUBSTRING UPDATETEXT
TEXTPTR WRITETEXT
TEXTVALID
永生天地 2010-11-23
  • 打赏
  • 举报
回复
没用过rpt文件,帮你顶
吴青峰 2010-11-23
  • 打赏
  • 举报
回复
看到的内容不是我想要的
我主要是想把这些内容放到表里面!
claro 2010-11-23
  • 打赏
  • 举报
回复
先把它用查询分析器打开,看看内容再说。
zjl8008 2010-11-23
  • 打赏
  • 举报
回复
想把现在表数据生成由insert 语句组成的sql文件的话用这个;
create proc [dbo].[proc_insert] (@tablename varchar(256))

as

begin

set nocount on

declare @sqlstr varchar(4000)

declare @sqlstr1 varchar(4000)

declare @sqlstr2 varchar(4000)

select @sqlstr='select ''insert '+@tablename

select @sqlstr1=''

select @sqlstr2=' ('

select @sqlstr1= ' values ( ''+'

select @sqlstr1=@sqlstr1+col+'+'',''+' ,@sqlstr2=@sqlstr2+name +',' from (select case

-- when a.xtype =173 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.length*2+2)+'),'+a.name +')'+' end'

when a.xtype =104 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(1),'+a.name +')'+' end'

when a.xtype =175 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'

when a.xtype =61 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'

when a.xtype =106 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'

when a.xtype =62 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'

when a.xtype =56 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(11),'+a.name +')'+' end'

when a.xtype =60 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(22),'+a.name +')'+' end'

when a.xtype =239 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'

when a.xtype =108 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'

when a.xtype =231 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'

when a.xtype =59 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'

when a.xtype =58 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'

when a.xtype =52 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(12),'+a.name +')'+' end'

when a.xtype =122 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(22),'+a.name +')'+' end'

when a.xtype =48 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(6),'+a.name +')'+' end'

-- when a.xtype =165 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.length*2+2)+'),'+a.name +')'+' end'

when a.xtype =167 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'

else '''NULL'''

end as col,a.colid,a.name

from syscolumns a where a.id = object_id(@tablename) and a.xtype <>189 and a.xtype <>34 and a.xtype <>35 and a.xtype <>36

)t order by colid



select @sqlstr=@sqlstr+left(@sqlstr2,len(@sqlstr2)-1)+') '+left(@sqlstr1,len(@sqlstr1)-3)+')'' from '+@tablename

-- print @sqlstr

exec( @sqlstr)

set nocount off

end

zjl8008 2010-11-23
  • 打赏
  • 举报
回复
用sql2000或2005中的那个导入导出工具 可以导入到sql中的一个表
王向飞 2010-11-23
  • 打赏
  • 举报
回复
数据量有多大?什么版本的数据库2008可以直接生成脚本
吴青峰 2010-11-23
  • 打赏
  • 举报
回复
还可以加分。
吴青峰 2010-11-23
  • 打赏
  • 举报
回复
或者把数据库表导成.sql文件也行。

22,300

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧