Skip to content
Advertisement

Tag: tsql

Validation trigger not working in SQL Server

I am working on a trigger for a class project. I have a table named salesman with a column named type. All employees in the table currently have a type of full, part or temp. The purpose of the trigger is to check a newly inserted row’s type and make sure that it matches one of the three that already

Why can’t I add a column to an existing table with a checkConstraint that references other columns in SQL

I’m using SQL Server and am trying to add a column and a check constraint. I’ve found that the following works: However a less verbose way of writing this does not work: The following error is output: Column CHECK constraint for column ‘isTrue’ references another column, table ‘table’. Looking at docs and SO I was unable to determine why this

String or binary data of ” would be truncated

I’m trying to resize a column down to 64 characters in length: but I get the following error: String or binary data would be truncated in table ‘dbo.consumption’, column ‘resourceGroup’. Truncated value: ”. This doesn’t make sense to me: how can you truncate nothing? Any help would be appreciated. Answer Thanks to comments by @MartinSmith and @DaleK, I think I’ve

Using SSIS OR T-SQL Split a column of quoted & unquoted comma separated values into multiple columns

I have comma separated data in a column named C0. The data in C0 looks like this: C0 “Pacey LLC.”,213830ZZ,11/1/2017,11/1/2017,”297,311.74″,”2,371.40″,0.00,”1,325.18″,0.00,42.22,”123,986.56″ Mike The Miker,9814140VCD,12/1/2018,12/1/2018,”3,917,751.99″,”419,743.54″,”36,642.66″,”344,090.43″,0.00,10.00,”2,434,671.06″ And I want it to end up like this: F1 F1 F3 F4 F5 F6 F7 F8 F9 F10 F11 “Pacey LLC.” 213830ZZ 11/1/2017 11/1/2017 297,311.74 2,371.40 0.00 1,325.18 0.00 42.22 123,986.56 Mike The Miker 9814140VCD 12/1/2018

SQL Generate per day records between dates

I have a table that where each record has start and end dates. I need to return a record for each day between start and end date fields (including the start and end dates). Using MS SQL Server. Example: Current data Data required: Looking for recommendations. Thanks. Answer You can use recursive cte :

Advertisement