Skip to content
Advertisement

Tag: sql-server-2005

SQL – Subtracting a depleting value from rows

I have a situation where I need to take a “quantity consumed” from one table, and apply it against a second table that has 1 or more rows that are “pooled lots” of quantities. I’m not sure how to describe it better, here’s what I mean from a table perspective: I need a resulting rowset from a SQL query that

Dynamically name indexes in SQL Server 2005?

As most people who work with Sql Server know, you can declare a temporary table like so: …this will create a primary key and a default constraint on this temporary table; the names for these objects will be unique, dynamically created by Sql Server. Is it possible to create a dynamically named index for the table after it’s been created?

Referring to a Column Alias in a WHERE Clause

I get “invalid column name daysdiff”. Maxlogtm is a datetime field. It’s the little stuff that drives me crazy. Answer Normally you can’t refer to field aliases in the WHERE clause. (Think of it as the entire SELECT including aliases, is applied after the WHERE clause.) But, as mentioned in other answers, you can force SQL to treat SELECT to

How to delete all duplicate records from SQL Table?

Hello I have table name FriendsData that contains duplicate records as shown below I want to remove duplicate combinations rows using MS SQL? Remove latest duplicate records from MS SQL FriendsData table. here I attached image which highlights duplicate column combinations. How I can removed all duplicate combinations from SQL table? Answer Try this See here Or here is more

Simple DateTime sql query

How do I query DateTime database field within a certain range? I am using SQL SERVER 2005 Error code below Note that I need to get rows within a certain time range. Example, 10 mins time range. Currently SQL return with Incorrect syntax near ’12’.” Answer You missed single quote sign: Also, it is recommended to use ISO8601 format YYYY-MM-DDThh:mm:ss.nnn[

Advertisement