My query doesn’t seems to parse information_type STEP TO REPRODUCE: Take AdventureWork or any other test database Right click on your test database > Tasks > Data Discovery and Classification > Classify Data… and classify a bunch of data Now use this query to check your information_type column (here I’m using AdventureWork2019): Paste this select and execute As you can
Tag: tsql
T-SQL :: generate random Swiss National Identification Number (AHV/AVS)
I woul like to generate random Swiss National Identification Number (AHV/AVS). I found a website that can do that and if I look at the source code of the same page I can alos see the JavaScript code that can generate it. The numbers are generated following this pattern: 756: is the prefix number, it never changes 1234: is a
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
How to pull rows from a SQL table until quotas for multiple columns are met?
I’ve been able to find a few examples of questions similar to this one, but most only involve a single column being checked. SQL Select until Quantity Met Select rows until condition met I have a large table representing facilities, with columns for each type of resource available and the number of those specific resources available per facility. I want
Recursive query to get totals by distinct item from a row of a data
I have SQL data that looks like the following: How can I recurse through this data to get total wins, draws, losses by team for both home and away? My output would look something like: I was able to get this done in a very linear way by simply get a list of distinct teams and for each team looping
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
SQL Statement with the same multiple subqueries running very slow
I am hoping someone here can help me. I have been given this query that takes a long time to run (over 30 min). I have been trying to rewrite the query but with no luck thus far. I am posting an example of the query so that you can get an idea of what it is I am trying
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 :