急啊!!如何读取一个数据库的字段,并生成一个数列,写入到另外一个表中的一个字段?
急啊从数据库表A提取了字段news_id,总共有10条分别1234510何提取些数字生成数列1|2|3|4|5|...|10,数列写入表B中的ccid字段呢拜托各位了给详...
急 啊从数据库表A提取了字段news_id, 总共有10条分别1234510何提取些数字生成数列 1|2|3|4|5|...|10, 数列写入表B中的ccid字段呢拜托各位了给详细ASP代码吧,拜托了
展开
2个回答
展开全部
dim sSQL as String
sSQL = "declare @NewsID varchar(1000) "
sSQL = sSQL & " set @NewsID = '' "
sSQL = sSQL & " select @NewsID = @NewsID + '|' + news_id from a "
sSQL = sSQL & " set @NewsID = substring(@NewsID, 2, len(@NewsID) - 1) "
sSQL = sSQL & " insert into b (ccid) values(@NewsID) "
这些是SQL语句.你把这个语句赋给recordset然后excute下就可以了.
sSQL = "declare @NewsID varchar(1000) "
sSQL = sSQL & " set @NewsID = '' "
sSQL = sSQL & " select @NewsID = @NewsID + '|' + news_id from a "
sSQL = sSQL & " set @NewsID = substring(@NewsID, 2, len(@NewsID) - 1) "
sSQL = sSQL & " insert into b (ccid) values(@NewsID) "
这些是SQL语句.你把这个语句赋给recordset然后excute下就可以了.
追问
能帮我写一下完整的ASP代码吗?拜托了
追答
加我QQ,给你远程.369508063
Dim conn As ADODB.Connection
set conn = server.createobject("adodb.connection")
conn.open "连接数据库的串"
dim sSQL As String
sSQL = "declare @NewsID varchar(1000) "
sSQL = sSQL & " set @NewsID = '' "
sSQL = sSQL & " select @NewsID = @NewsID + '|' + news_id from a "
sSQL = sSQL & " set @NewsID = substring(@NewsID, 2, len(@NewsID) - 1) "
sSQL = sSQL & " insert into b (ccid) values(@NewsID) "
conn.execute(sSQL)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询