Tag Info

New answers tagged

1

Quick and dirty, but I'm assuming you'll be putting this into a more formalizing procedure for spitting out names. DECLARE @Firstname nvarchar(50) DECLARE @Lastname nvarchar(50) SET @Firstname = 'Marc-Oliver' SET @Lastname = 'Saint-Onge' SELECT @FirstName, @Lastname IF CHARINDEX('-', @FirstName) <> 0 SELECT SUBSTRING(@Firstname, 1, 1) + '.' + ...


0

REAL and FLOAT are approximate data types. FROM: https://msdn.microsoft.com/en-us/library/ms173773.aspx "Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly."


6

Stop using REAL and use DECIMAL instead. REAL and FLOAT are approximate data types and can't represent all numbers in the nice, rounded way you are used to. Compare these: DECLARE @a REAL = 0.23, @b REAL = 0.24; SELECT AVG(r) FROM (SELECT r = @a UNION SELECT r = @b) AS x; Result: 0.234999999403954 Now using DECIMAL instead: DECLARE @a DECIMAL(10,4) = ...


0

With thanks to Colin 't Hart this worked: DELIMITER $ CREATE PROCEDURE showUnique( IN col CHAR(64)) BEGIN SET @s=CONCAT('SELECT COUNT(DISTINCT ',col,') FROM president); PREPARE stmt from @s; EXECUTE stmt; DEALLOCATE PREPARE stmt; END $ delimiter ; CALL showUnique(last_name)


0

My solution is to save the spreadsheet as a tab-delimited "matrix" file, run the following "data structure conversion" program, then import the resulting tab-delimited "relation" file into Access. The Python 3.4 code: import csv source_path = 'matrix.txt' target_path = 'relation.txt' source_deli = '\t' target_deli = '\t' target_head = ("Name", "Activity", ...


4

No need for such a function, this is already built-in: select id_field, string_agg(field_traspose, ', ' order by field_traspose) from the_table group by id_field order by id_field;


0

You must compile your CLR code as a library (.dll) using the .NET build tools or Visual Studio to create the assembly. See the MSDN article on Deploying CLR Database Objects for details. Assuming your source file is Concatenate.vb, you can compile from a command prompt (set your PATH to include the appropriate .NET Framework directory or cd to it): vbc ...


0

Answering my own question, I found this link, which contains the answer: ...by having this as a function on your update, you are essentially calling the function as many number of times as there are rows in the table. This is not the best way to do this, and is known as row-by-row processing, rather than set-based. Try and take the processing ...



Top 50 recent answers are included