在sql server中自动为上载的文件创建带有列的表 [英] Create table with columns in sql server automatically for uploaded files

查看:119
本文介绍了在sql server中自动为上载的文件创建带有列的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在我的网页中上传.csv格式文件,并且当我单击更新"按钮时,它将自动创建带有列的表
在这里
文件名=表名和
文件的第一行(标题)=表的列

如何在MS SQL Server中为其编写代码.

i want upload only .csv formate files in my web page and as soon as i click on Update button it will automatically create table with columns
here
file name= table name and
first row of the file (headings)= columns of the table

how to write the code for it in MS SQL server.

推荐答案

U应该尝试这样:

U should try like this :

ALTER PROCEDURE spName(
DECLARE @tableName VARCHAR(100),@columnName VARCHAR(50),@Query VARCHAR(8000) )
BEGIN 
SET @Query='CREATE TABLE '  + @tableName + '(' +@columnName + ' VARCHAR(200)'+ ')'
EXECUTE (@Query)
END 



//U应该从前端传递表名和列名

希望对您有所帮助



// U should pass table name and column name from front end

I hope this will help u


这篇关于在sql server中自动为上载的文件创建带有列的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆