How to print DateTime variable in the RAISERROR method?

The supplied value must be a constant or a variable. You cannot specify a function name as a parameter value. (from MSDN Executing Stored Procedures). You need to do something like this: declare @EffectiveStartDateText varchar(30) set @EffectiveStartDateText = cast(@EffectiveStartDate as varchar) declare @EffectiveEndDateText varchar(30) set @EffectiveEndDateText = cast(@EffectiveEndDate as varchar) RAISERROR ( ‘SPName: InsertUpdateLiquidityDateRule: Start … Read more

Update DataSet structure in Visual Studio to match new SQL Database Structure

From the MSDN Forums: If you right-click the TableAdapter in the Dataset Designer and click ‘Configure’ the TableAdapter Configuration Wizard opens where you can reconfigure the main query that defines the schema of your table. This should leave the additional TableAdapter queries (the additional methods) that were added after initial configuration. Of course the additional … Read more

Postgres date overlapping constraint

Ok i ended up doing this : CREATE TABLE test ( from_ts TIMESTAMPTZ, to_ts TIMESTAMPTZ, account_id INTEGER DEFAULT 1, product_id INTEGER DEFAULT 1, CHECK ( from_ts < to_ts ), CONSTRAINT overlapping_times EXCLUDE USING GIST ( account_id WITH =, product_id WITH =, period(from_ts, CASE WHEN to_ts IS NULL THEN ‘infinity’ ELSE to_ts END) WITH && ) … Read more

SELECT those not found in IN() list

You can use a derived table or temporary table for example to hold the list of CustomerId then find the non matching ones with EXCEPT. The below uses a table value constructor as a derived table (compatible with SQL Server 2008+) SELECT CustomerId FROM (VALUES(1), (79), (14), (100), (123)) V(CustomerId) EXCEPT SELECT CustomerId FROM Customers

How to save image in database using C# [closed]

Try this method. It should work when field when you want to store image is of type byte. First it creates byte[] for image. Then it saves it to the DB using IDataParameter of type binary. using System.Drawing; using System.Drawing.Imaging; using System.Data; public static void PerisitImage(string path, IDbConnection connection) { using (var command = connection.CreateCommand … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)