1

I need your help, I want to have one datatype for all databases but I can't.

Thanks for your help.

USE master
GO

SP_dropTYPE 'dtDate';
go

SP_ADDTYPE 'dtDate', date, 'not null'
go

GRANT REFERENCES ON TYPE::[dbo].dtDate TO public WITH GRANT OPTION ;
GRANT VIEW DEFINITION ON TYPE::[dbo].dtDate TO public WITH GRANT OPTION ;
GRANT EXECUTE ON TYPE::[dbo].dtDate TO public AS [dbo] ;
GO

DECLARE @x dtDate = GETDATE()

SELECT @x -- OK

-- ***
USE dbtest
GO

DECLARE @x dtDate = GETDATE() -- ERROR
SELECT @x -- ERROR

I'm getting this error:

Msg 2715, Level 16, State 3, Line 21
Column, parameter, or variable #1: Cannot find data type dtFechanac.
Parameter or variable '@x' has an invalid data type.

Stu
  • 30,392
  • 6
  • 14
  • 33
  • you can't do that. this is not possible in sql server – eshirvana Apr 24 '21 at 18:14
  • Does this answer your question? [Passing Table Valued parameter to stored procedure across different databases](https://stackoverflow.com/questions/9531769/passing-table-valued-parameter-to-stored-procedure-across-different-databases) – eshirvana Apr 24 '21 at 18:15

0 Answers0