當前位置:成語大全網 - 新華字典 - sql數據庫中各個表字段漢化問題

sql數據庫中各個表字段漢化問題

第壹步,寫壹個函數:

CREATE FUNCTION getChName (@FName varchar(20))

RETURNS nvarchar(20)

AS

BEGIN

DECLARE @Result nvarchar(20)

select @result=中文名 from B where 字段名=@FName

return @result

END

第二步,用execute得到結果:

execute ('select name as '+dbo.getChName('name')+',age as '+dbo.getChName('age')+',sex as '+dbo.getChName('sex')+' from A')