Showing posts with the label sql-server-2005

[FIXED] Referring to a Column Alias in a WHERE Clause

Issue SELECT logcount, logUserID, maxlogtm , DATEDIFF(day, maxlogtm, GETDATE()) AS daysdiff FROM…

[FIXED] How to get the name of a the student who got max marks in each subject?

Issue I have the following table Name | Subject | Marks -------------------------- a …

[FIXED] Combine SELECT statements. Help Needed

Issue I have the following two T-SQL statements that I really need to combine: SELECT Aircraf…

[FIXED] In a Data Warehouse scenario is there any disadvantage to using WITH(NOLOCK)

Issue I have a Kimball-style DW (facts and dimensions in star models - no late-arriving facts rows …

[FIXED] when were index statistics last updated?

Issue Is there a quick and easy way to list when every index in the database last had their statist…

[FIXED] Where we are giving password by using BCP command?

Issue I am pretty much new to bcp but I researched quite a bit and can not find any resource that s…

[FIXED] Backup SQL Schema Only?

Issue I need to create a backup of a SQL Server 2005 Database that's only the structure...no re…

[FIXED] Add empty row to query results if no results found

Issue I'm writing stored procs that are being called by a legacy system. One of the constraints…

[FIXED] How to get Time from DateTime format in SQL?

Issue I want to get only Time from DateTime column using SQL query using SQL Server 2005 and 2008 …

[FIXED] Best way to do nested case statement logic in SQL Server

Issue I'm writing an SQL Query, where a few of the columns returned need to be calculated depen…

[FIXED] Check if table exists in SQL Server

Issue I would like this to be the ultimate discussion on how to check if a table exists in SQL Serv…

[FIXED] Execution sequence of Group By, Having and Where clause in SQL Server?

Issue I am just confused with the execution sequence of a SQL query when we use GROUP BY and HAVIN…

[FIXED] Is a Primary Key necessary in SQL Server?

Issue This may be a pretty naive and stupid question, but I'm going to ask it anyway I have a…

[FIXED] SQL Server compare results of two queries that should be identical

Issue I am modifying a sql server 2005 stored procedure slightly for performance, and I would like …

[FIXED] Column name or number of supplied values does not match table definition

Issue In the SQL Server, I am trying to insert values from one table to another by using the below …