Declaring variable type based on a column type

 ̄綄美尐妖づ 提交于 2019-11-29 09:07:28

No you can't do this. The closest equivalent is User-Defined Data Types. This will give you a layer of abstraction that may help, but it is not the same as deriving a type from a column.

It may skirt the real issue, but you can "cheat" a little bit by

Select *
INTO #tmp
From MyTable
Where 1 = 0

Will automatically create a temp table with all columns with correct data types.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!