![]() |
| In SQL Server, mix data types. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: In SQL Server, mix data types. (/thread-38247.html) |
In SQL Server, mix data types. - shiv11 - Sep-21-2022 While reading an article of SQL server on wiki thought that, In SQL Server, is it possible to merge data types? i.e., to have a cell's value be both a text and a number, with the text being a constant? My table is named Contract. The value for the ContractID field should be "TCwxyz," where "TC" stands for text characters and "wxyz" for integers. The following is what I have, however it doesn't appear to be working: CREATE TYPE TenantContracts AS CHAR(6) CHECK (SUBSTRING(VALUE,1,2)='TC' AND (SUBSTRING(VALUE,2,4) AS SMALLINT) Any help would be much appreciated. Thank you. |