· 6 years ago · Mar 08, 2019, 12:14 AM
1IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'[dbo].[UserProfiles]') AND name = 'AllCheckboxesChecked')
2BEGIN
3 ALTER TABLE [dbo].[UserProfiles] ADD [AllCheckboxesChecked] [bit] CONSTRAINT [DF_UserProfiles_AllCheckboxesChecked] DEFAULT 0 NOT NULL
4 UPDATE [dbo].[UserProfiles] SET [AllCheckboxesChecked]=1 WHERE [CheckedBoxes] LIKE '%#ALL#%'
5END
6GO
7
8IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'[dbo].[UserProfiles]') AND name = 'AllCheckboxesChecked')
9BEGIN
10 ALTER TABLE [dbo].[UserProfiles] ADD [AllCheckboxesChecked] [bit] CONSTRAINT [DF_UserProfiles_AllCheckboxesChecked] DEFAULT 0 NOT NULL
11 GO
12 UPDATE [dbo].[UserProfiles] SET [AllCheckboxesChecked]=1 WHERE [CheckedBoxes] LIKE '%#ALL#%'
13END
14GO
15
16Connection type: Microsoft SQL Server / MSDE
17Connection mode: ODBC Driver
18ODBC Driver: SQL Server
19Use 64-bit ODBC resource: No
20
21Statement1
22GO
23Statemetn2
24
25BEGIN
26 DROP TABLE dbo.UserProfiles
27END
28GO
29CREATE TABLE dbo.UserProfiles (CheckedBoxes VARCHAR(100))
30GO
31
32IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'[dbo].[UserProfiles]') AND name = 'AllCheckboxesChecked')
33BEGIN
34 ALTER TABLE [dbo].[UserProfiles] ADD [AllCheckboxesChecked] [bit] CONSTRAINT [DF_UserProfiles_AllCheckboxesChecked] DEFAULT 0 NOT NULL
35 UPDATE [dbo].[UserProfiles] SET [AllCheckboxesChecked]=1 WHERE [CheckedBoxes] LIKE '%#ALL#%'
36END
37GO
38
39Msg 207, Level 16, State 1, Line 5
40Invalid column name 'AllCheckboxesChecked'.