sql-server-2008

Help with SQL Server query

I have table that contain name and date. I need to count how many names I have in a one day, and make average to all days. How to do it? Thanks in advance ...

Is NOLOCK the default for SELECT statements in SQL Server 2005?

I have only SQL Server 2008R2 installed though I need to communicate with customers having 2005. [1] tells: "NOLOCK This does not lock any object. This is the default for SELECT operations. It does not apply to INSERT, UPDATE, and DELETE statements" [2] doesn't seem to mention it, but my checking in SSMS/SS 2008R2 shows that n...

String concatenation issue in CTE SQL

I have the following CTE SQL WITH Tasks AS ( SELECT TaskID, ParentTaskID, CAST(SortKey AS nChar) AS sort_key /*,cast(SortKey as char) as sort_key */ FROM oaTasks AS s WHERE (TaskID = 1) UNION ALL SELECT s2.TaskID, s2.ParentTaskID ,Cast( '0.'+ cast(Tasks_2.sort_key as...

how do i combine two selects from one table where one has a GROUP BY and the other has a DISTINCT

Both of these work individually SELECT PONumber, count(RequestNumber) as "InNumOfRequests", sum(Amount) as "SumofAmounts" FROM tableView GROUP BY PONumber SELECT DISTINCT PONumber, (10 * ceiling((DATEDIFF(day,POApprovedDate,GETDATE()))/10)) AS "BINofDaysSincePOApproved" ...

how to create a table from an excel sheet?

Is there an easy tutorial? I'd like to create a table that exactly matches the excel table, is it possible to do something like "create table from excel sheet"? ...

Sql Server 2008 Instalation

Can I install and use sql server 2005 and 2008 in the same time on the same machine because I have an old software that use SQL server 2005 and another new one that use Sql server 2008 ...

Checking each row of datagrid view and then displaying error message linked to each row under the hyperlink button on the data grid view

Hi, Stage1 My web portal checks if there is a csv file selected and then uploads a csv file through file upload option saving i tonto a tempdatabase on sql Server and displays the data on the grid view. The grid view contain fixed 29 columns with a hyperlink named (view) and a check field. Stage 2 & 3 What I want is, once the file ...

Storing unknown datatype in MS SQL Server Database

Hi, Does any one has an idea of whats the best practice to store an unknown data type in a table. Basically I would need to store types like bit, smallint, int, real and nvarchar in the same "value" column, for later interpretation by a .NET application. I was trying to achieve the best possible solution not to compromise the performan...

How to set Database Audit Specification for all the tables in db

I need to create an audit to track all CRUD events for all the tables in a database , now i have more than 100 tables in the DB , is there a way to create the specification which will include all the tables in the DB ? P.S : I am using SQL Server 2008 ...

Is it possible to pass a parameter to trigger in SQL server database?

Table can have trigger on insert/delete/update. Trigger will be fired internally by DB engine. Is it possible to pass a parameter to trigger in SQL server database like StoreProcedure? ...

SQL Filegroup degrading performance

On our dev boxes, our database resides entirely in the PRIMARY filegroup, and everything works fine. On one of our production servers, recently upgraded from 2005 to 2008, we noticed it was performing slower than it should. On this machine, there are two filegroups - PRIMARY and INDEXES. Both filegroups contain 1 file per logical vo...

Basic management scipts that you run in your database / instance?

What kind of basic management/audit scripts do you run in your databases or in an instance? There may be lots of them, but I would like to know (get hints) what kind of task would be most valuable when managing databases or an instance. And also what kind of reporting do you have from your databases (in a management perspective)? ...

What does "materializing" temporary table mean?

I have noticed quite a few mentions of the word "materializing" when people are talking about using temporary tables in SQL Server. Can someone expand on what it is that means? I am just trying to get a better understanding of what that means in terms of using temp tables? Thanks! S ...

Does SQL Server 2008 Service Pack 2 Apply to SQL Server 2008 R2?

I've been using SQL Server 2008 R2 for my development. I noticed that service pack 2 for SQL Server 2008 just came out. However, I checked here and Microsoft does not provide a link to any of the service packs for SQL Server 2008 R2. So it is not clear to me whether or not I should apply their service pack to my instance of SQL Server 20...

What indexes will I need to make on this SQL Server table?

Hi folks, I have the following sql query for a SQL Server 2008 db. SELECT TOP(@NumberOfStreetResults) LocationType, LocationId, Name FROM [dbo].[LocationNames] WHERE CONTAINS(Name, @SearchQuery) AND LocationType = 7 Notice how I'm using the CONTAINS keyword? I have an FTS on the Name field. I'm not sure what index(s) I need to ...

migrating sql server 2008 database to sql server ce

Hi, Im using sql server 2008 database on the server side but I want to give customers possibility to hold local database (using sql server 2008 CE). Before migrating to 2005 I was manually writing scripts to create local CE database. Is there any way to automate this task in sql server 2008 ? Maybe its common problem ? thanks for he...

SQL2008 R2 Capturing Dynamic Sql through DDL Trigger

I have setup a DDL trigger @ Database level to capture all DDL changes and to log them into a Table. When I issue a Dynamic SQL statment such as set @sql="SELECT * INTO __Temp__XLPriceList FROM OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source="\\DEV-v1\d$\DEV-V1\EXCEL_BOOKS\EXPRESSLANE\DISCOUNTS\08Oct10-DISCOUNT-010-141.XLS"; ...

Modify table: not null to null

How to change one attribute in a table using T-SQL to allow nulls (not null --> null)? Alter table maybe? ...

Reporting Services - deployment and global/shared configuration between reports

Is it possible to add global variables that are shared among reports in SQL Server Reporting Services? I know it's possible to add variables for a report but I want the same variables to be used from many different reports. Also, is it possible to have different configurations for different servers so that when reports are deployed they...

Entity Framework 4 : Bad performance with SQL Server 2008

I'am developing a software based on Entity Framework to handle data in a MS SQL Server 2008 database. [Trouble 1] I've just tried to insert some small data (about 2 Mb) from my progam to the database : the performance are very bad ! It takes more than 1 minute to insert these datas ! I've try to generate pre-compiled views, I've got t...