Skip to content
Advertisement

Tag: sql-server-2008

drop trigger if exists and create

I would like to check if the trigger exists on [tbl] and create another one. I tried it this way but didn’t work. What am I doing wrong? Answer The [name] field in sys.objects will contain only the actual name (i.e. trg), not including the schema (i.e. dbo in this case) or any text qualifiers (i.e. [ and ] in

A constant expression was encountered in the ORDER BY list

Below is my dynamic query and it’s not working. It threw: A constant expression was encountered in the ORDER BY list, position 2. Original dynamic query: Extracted Query: If I remove second order by line, CASE WHEN ‘ItemDescription’=’ItemDescription’ AND ‘0’= ‘1’ THEN cteForPriceVen.ItemDescription END DESC the query seems working. Answer The second line: Is equivalent to NULL. You can’t order

convert datetime (mm/dd/YYYY) to decimal(YYYYmmDD)

I am trying to get the following result in Sql: example: 23/05/2014 to 20142305 but get this: result:41780 anyone know how you can get the following format?? (if possible ??) regards and thanks Answer In many databases (including SQL Server), you can just do: Some databases don’t support these functions, so you might need extract(datepart from datetime) or a similar

How to fill missing dates and values in partitioned data?

How to fill missing dates and values in partitioned data? I’m having a lot of trouble Googling this as most of the posts seem to feature Oracle databases, and I’m working with Microsoft SQL Server. I have the following hypothetical table: I want to fill in the dates in between the gaps and copy over the value from the most

Advertisement