MoonLight
MoonLight

Reputation: 37

How to use constant/variable in a SQL Server CE 4 script?

I have this script:

DELETE FROM [Tags] WHERE Id = CONVERT(uniqueidentifier, '7373D1A0-CB6A-4207-87C4-AE2939FD20C0');
GO
INSERT INTO [Tags] VALUES (CONVERT(uniqueidentifier, '7373D1A0-CB6A-4207-87C4-AE2939FD20C0'), 'Business');
GO

I want to declare a @businessId constant to hold the result from my

CONVERT(uniqueidentifier, '7373D1A0-CB6A-4207-87C4-AE2939FD20C0') 

The end result should look cleaner:

DELETE FROM [Tags] WHERE Id = @businessId;
GO
INSERT INTO [Tags] VALUES (@businessId, 'Business');
GO

Is there a way to do this in SQL Server CE 4? If no, is there a way to do this in SQL Server?

Thank you for your help.

Upvotes: 0

Views: 2719

Answers (1)

Nathan Fisher
Nathan Fisher

Reputation: 7941

In T-SQL (SQL Server) you would write

Declare @businessId UniqueIdentifier;
set @businessId = '7373D1A0-CB6A-4207-87C4-AE2939FD20C0';

I would imagine that it is the same in SQL Server CE but I will confirm it;

Upvotes: 1

Related Questions