Showing posts with label occurs. Show all posts
Showing posts with label occurs. Show all posts

Thursday, March 29, 2012

Create an data type with identity(1, 1) property

Hello!

Code Snippet


--I'm trying this command:
create type int8 from tinyint identity(1,1) not null


But, an error occurs: don't possible create an data type with identity property....... Correct?

How to create an data type with identity property? The 'sys.sp_addextendedproperty' SP is the solution? An example, please?

Bye!

The IDENTITY property is linked to a table -as well as a datatype.

CREATE TABLE MyTable

( RowID int IDENTITY,

MyDate varchar(20)

)

You cannot simply CREATE TYPE or DECLARE a variable and also have an IDENTITY property for the type/variable.

|||another example?

execute('
select
identity(int,1,1) as id,
sum(trunk.count) as count,
sum(trunk.duration) as duration,
sum(trunk.charge1) as charge1,
trunk.trunk,
trunk.currency
into
#utilisation
from
(
select
count(local.callid) as count,
sum(local.duration) as duration,
sum(isnull(local.charge1,''0'')) as charge1,
local.trunk,
local.currency
from
tt32.dbo.trunk t,
database.dbo.local01 local
where
local.trunk = t.trunk
group by

local.trunk,
local.currency
)trunk
group by

trunk.trunk,
trunk.currency

--showing the result
select
id,
isnull(count,''0'') as count,
duration,
isnull(charge1,''0'') as charge1,
trunk,
currency
from #utilisation
|||: (

Ok. Thanks!

Bye!