Freitag, 18. November 2016

SQL Server Management Studio Syntax error in TextHeader of View


In Query Windows enter this: 
 
sp_helptext N'NameOfView'
 
 
If you want to get The Create Table Statment:
SELECT c.name +' ' +t.name + 
    case t.name 
      when 'nvarchar' 
        then ' ('+convert(varchar,c.max_length/2)+') '
      else ''
    end +','
  --,t.name data_type
  --,c.max_length max_length
  --,c.precision precision
  --,c.scale scale
  --,c.is_nullable is_nullable
  --,c.is_identity is_identity
  --,c.collation_name collation_name
FROM sys.columns c
  ,sys.objects o
  ,sys.types t
WHERE c.object_id = o.object_id
  AND t.system_type_id = c.system_type_id
  and o.name = 'yourTableName'
  and t.name != 'sysname'