Showing posts with label defined. Show all posts
Showing posts with label defined. Show all posts

Friday, March 30, 2012

Mapping User Defined Data Type to Base Data Type

Hi,

I am trying to map a user-defined datatype to it's base data type in SQL Server 2000/2005. Let's say I have created a udt named ssn which is actually a char datatype with length 9. I need a query that would map the udt with the base datatype and give the typename of both. I have been using the sys.types table but I still can't see the link. Any help would be appreciated.

Thanks

Here is an Information_Schema view that I created a long time ago in my databases. Most of it I actually copied from a sql 2000 system sproc. You should be able to use it to construct what you need:

SELECT TOP 100 PERCENT
*,
ColumnName + ' ' +
UsedDataType +
CASE WHEN UserDefinedDataType IS NULL THEN
CASE WHEN collationID IS NOT NULL THEN
'('+CAST(CharacterMaxLength AS VARCHAR(10))+')'
ELSE ''
END
ELSE
''
END
AS ColumnDefinition,
ColumnName + ' ' +
UPPER(basedatatype) +
CASE WHEN collationID IS NOT NULL THEN '('+CAST(CharacterMaxLength AS VARCHAR(10))+')' ELSE '' END
AS ColumnDefinition2,
UsedDataType +
CASE WHEN UserDefinedDataType IS NULL THEN
CASE WHEN collationID IS NOT NULL THEN
'('+CAST(CharacterMaxLength AS VARCHAR(10))+')'
ELSE ''
END
ELSE
''
END
AS DefinedDataType
FROM
(
SELECT
DB_NAME() AS DatabaseName,
CASE obj.xtype WHEN 'U' THEN 'TABLE' WHEN 'V' THEN 'VIEW' WHEN 'P' THEN 'PROCEDURE' END AS ObjectType,
USER_NAME(obj.uid) AS TableSchema,
obj.name AS TableName,
col.name AS ColumnName,
col.colid AS ColumnPosition,
com.text AS DefaultValue,
CASE col.isnullable WHEN 1 THEN 'YES' ELSE 'NO' end AS IsNullable,
spt_dtp.LOCAL_TYPE_NAME AS BaseDataType,
CASE WHEN typ.xusertype > 256 THEN typ.name ELSE UPPER(typ.name) END AS UsedDataType,
CONVERT(INT, OdbcPrec(col.xtype, col.length, col.xprec) + spt_dtp.charbin) AS CharacterMaxLength,
NULLIF(col.xprec, 0) AS NumericPrecision,
col.scale AS NumericScale,
CONVERT(SYSNAME, CASE WHEN typ.xusertype > 256 THEN typ.name ELSE NULL END) AS UserDefinedDataType,
OBJECT_NAME(cdefault) AS ColumnDefaultName ,
typ.CollationID
FROM
sysobjects obj,
master.dbo.spt_datatype_info spt_dtp,
systypes typ,
syscolumns col
LEFT OUTER JOIN syscomments com on col.cdefault = com.id AND com.colid = 1,
master.dbo.syscharsets a_cha
WHERE
obj.id = col.id AND
typ.xtype = spt_dtp.ss_dtype AND
(spt_dtp.ODBCVer is null or spt_dtp.ODBCVer = 2) AND
obj.xtype in ('U', 'V', 'P') AND
col.xusertype = typ.xusertype AND
(
spt_dtp.AUTO_INCREMENT IS NULL OR spt_dtp.AUTO_INCREMENT = 0) AND
a_cha.id = ISNULL(CONVERT(TINYINT, CollationPropertyFromID(col.collationid, 'sqlcharset')),
CONVERT(TINYINT, ServerProperty('sqlcharset'))
) and obj.type = 'u'

) a
ORDER BY
TableName, ColumnPosition ASC

Wednesday, March 28, 2012

Maping loging to users databases in SQL2000

I defined some jobs to move production database in analyst database on other
server. When jobs restore the database on analisys server, the login to the
user are not preserve. I've run an DTS to copy login from production server
to analisys server. Have anybody some clues about this problem. Thank you!Hi,
it is always better to make a script of all user logins created to restore
it over another server , BTW have you include users into that DTS package to
move !
:-)
Regards
--
Andy Davis
Activecrypt Team
---
SQL Server Encryption Software
http://www.activecrypt.com
"tudor" wrote:

> I defined some jobs to move production database in analyst database on oth
er
> server. When jobs restore the database on analisys server, the login to th
e
> user are not preserve. I've run an DTS to copy login from production serve
r
> to analisys server. Have anybody some clues about this problem. Thank you!
>
>|||Hi,
one more thing make me curious that why you make DTS to move DATABASE , is
backup /restore , attach / detach not working, how ever here is a article
FYI :
http://vyaskn.tripod.com/moving_sql_server.htm
:-)
Regards
--
Andy Davis
Activecrypt Team
---
SQL Server Encryption Software
http://www.activecrypt.com
"tudor" wrote:

> I defined some jobs to move production database in analyst database on oth
er
> server. When jobs restore the database on analisys server, the login to th
e
> user are not preserve. I've run an DTS to copy login from production serve
r
> to analisys server. Have anybody some clues about this problem. Thank you!
>
>|||Hi,
here is one more link for your joy , it will list associated role for users:
http://www.sql-server-performance.c...?TOPIC_ID=10504
Andy Davis
Activecrypt Team
---
SQL Server Encryption Software
http://www.activecrypt.com
"tudor" wrote:

> I defined some jobs to move production database in analyst database on oth
er
> server. When jobs restore the database on analisys server, the login to th
e
> user are not preserve. I've run an DTS to copy login from production serve
r
> to analisys server. Have anybody some clues about this problem. Thank you!
>
>

Friday, March 9, 2012

Managing XML field with Enterprise Manager

With SQL Server 2000, I have a table with a field called fldhistory, defined
as a ntext [16] field.
This column is intended for storing some archived history data in XML format.
I have an example XML which is valid and:
1) has <1300 characters, including spaces
2) Wel-formed, readable by IE
3) <10 lines
However, I can't put anything more than say a few hundred charaters in this
column under Enterprise Manager (for testing purposes), the past option is
simply disabled and if I try ctrl-V, I get a Windows warning tone.
why is this and how can I fix this? the ntext column should be capable of
handling >1300 characters!Hello,
Please refer to the following information in SQL server Books Online(BOL):
Topic: Adding ntext, text, or image Data to Inserted Rows
---
These are ways to add ntext, text, or image values to a row:
" Specify relatively short amounts of data in an INSERT statement in the
same way char, nchar, or binary data is.
" Use the WRITETEXT statement. For more information, see WRITETEXT.
" ADO applications can use the AppendChunk method to specify long amounts
of ntext, text, or image data. For more information, see Managing Long Data
Types.
" OLE DB applications can use the ISequentialStream interface to write new
ntext, text, or image values. For more information, see BLOBs and OLE
Objects.
" ODBC applications can use the data-at-execution form of SQLPutData to
write new ntext, text, or image values. For more information, see Managing
text and image Columns.
" DB-Library applications can use the dbwritetext function. For more
information, see Text and Image Functions.
---
You can use above ways to insert ntext data. Please also refer to the
following topics in BOL:
"Using text and image Data"
"Managing ntext, text, and image Data"
"text, ntext, and image Data When text in row Is Set to ON"
You can also refer to the following articles which provide good information:
194975 How To Read and Write BLOBs Using GetChunk and AppendChunk
http://support.microsoft.com/?id=194975
258038 How To Access and Modify SQL Server BLOB Data by Using the ADO Stream
http://support.microsoft.com/?id=258038
I hope the information is helpful.
Sophie Guo
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
=====================================================When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.

Managing user-defined properties for report items

[crossposted to MS Community forums as well]
I have defined a user-defined property for several reports. The coding
for GetProperty/SetProperty is straightforward, but it looks as if
there is no management/admin capability through Report Manager or SQL
Management Studio for user-defined properties. Is this correct?
If that capability does not exist, Is there any plan for future
versions of RM/SqlMgtStudio to support getting/setting user-defined
properties?
Thanks!
Regards,
MichaelJust to follow up on this - I've submitted this as a product request to
Microsoft - they've basically postponed any action on it and said
they'll look at it for a future release. *shrug*
Michael

Monday, February 20, 2012

Management Studio, Save as... dialog before running External Tools

Hi.

In Management Studio I have defined some external tools. When I call my external tool from Tools menu and I have query scripts that are not saved I get "Save File As..." dialog for EVERY not saved script before running my External Tool. This is frustrating because sometimes I have a lot of not saved scripts and my External Tool doesn't need saved script files. How to run External tool in Mangement Studio without this frustrating "Save File As..." dialog box?

Kamil

I get the same thing. I can click cancel and the tool still opens, but it is annoying.