Home  >  Article  >  Database  >  uniqueidentifier转换成varchar数据类型的sql语句

uniqueidentifier转换成varchar数据类型的sql语句

WBOY
WBOYOriginal
2016-06-07 18:02:471200browse

uniqueidentifier转换成varchar数据类型的sql语句,需要的朋友可以参考下。

代码如下:
---涂聚文 Geovin Du
DECLARE @myid uniqueidentifier
SET @myid = NEWID()
SELECT CONVERT(char(255), @myid) AS 'char';
GO
--涂聚文 Geovin Du
declare @allstring char(255),@AreaUid Uniqueidentifier
set @AreaUid='37A1DA94-4AC6-4ED0-B96F-BA3FE6AEACC8'
set @allstring= cast(@AreaUid as char(255))
select @allstring
--涂聚文 Geovin Du
declare @allstring char(255),@AreaUid Uniqueidentifier,@s varchar(200)
set @AreaUid='37A1DA94-4AC6-4ED0-B96F-BA3FE6AEACC8'
set @allstring= CONVERT(char(255),@AreaUid)
set @s=cast(@allstring as varchar(200))
select @allstring,@s
--涂聚文 Geovin Du
declare @allstring char(255),@AreaUid Uniqueidentifier,@s varchar(200)
set @AreaUid='37A1DA94-4AC6-4ED0-B96F-BA3FE6AEACC8'
select @s=CONVERT(varchar(200),cast(@AreaUid as char(225)))
select @s
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn