SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION Strip_XML_NS
(
@xml varchar(max)
)
RETURNS varchar(max)
AS
BEGIN
DECLARE @stripped varchar(max)
declare @i int
set @i = CHARINDEX('"', @xml) - LEN('xmlns="')
declare @f int
set @f = CHARINDEX('"', @xml, CHARINDEX('"', @xml) + 1) + 1
declare @ns varchar(max)
set @ns = SUBSTRING(@xml, @i, @f - @i)
set @stripped = REPLACE(@xml, @ns, '')
RETURN @stripped
END
GO
Showing posts with label sqlserver. Show all posts
Showing posts with label sqlserver. Show all posts
Tuesday, November 10, 2015
Tuesday, October 20, 2015
MS SQL Server - Select Columns Names with System Type for User Table
declare @tableName varchar(max)
set @tableName = 'Products'
select so.name as TableName, sc.name as ColumnName, st.name as SystemType
from sys.columns sc
inner join sys.objects so on (sc.object_id = so.object_id)
inner join sys.types st on (sc.system_type_id = st.system_type_id)
where
(so.type_desc = 'USER_TABLE')
and
(so.name = @tableName)
set @tableName = 'Products'
select so.name as TableName, sc.name as ColumnName, st.name as SystemType
from sys.columns sc
inner join sys.objects so on (sc.object_id = so.object_id)
inner join sys.types st on (sc.system_type_id = st.system_type_id)
where
(so.type_desc = 'USER_TABLE')
and
(so.name = @tableName)
Subscribe to:
Posts (Atom)