sql-server-2008

how to Implement Audit DB using new SQL 2008 Audit features?

SQL 2008 has audit feature.I need to use that but I dont know how.what are the step and requirement for using audit feature. ...

Which is faster: JOIN with GROUP BY or a Subquery?

Let's say we have two tables: 'Car' and 'Part', with a joining table in 'Car_Part'. Say I want to see all cars that have a part 123 in them. I could do this: SELECT Car.Col1, Car.Col2, Car.Col3 FROM Car INNER JOIN Car_Part ON Car_Part.Car_Id = Car.Car_Id WHERE Car_Part.Part_Id = @part_to_look_for GROUP BY Car.Col1, Car.Col2, Car.Col3 ...

System date is displaying when the value is NULL in date field in SSRS report?

Below is my SQL query used in SSRS report SELECT Claimname,CONVERT(VARCHAR,ClaimResponsedate,101) FROM Claim WHERE DataSourceID = 100011 From the above query 'ClaimResponsedate' may get NULL values but in SSRS report for this field displaying 1/1/1990 when the value comes as NULL. I need to display empty value in report if the date va...

INSERT INTO results_table EXEC sproc from within a scheduled job

I'm trying to setup a scheduled job that with one step that would insert the results from a sproc into a table. INSERT INTO results_table EXEC sproc The job executes and reports a success. Yet nothing gets inserted into a table. When I execute the same script from the SSMS the results are inserted. What might cause the problem? ** E...

SQL Server 2008 CTE Recursion

Hello. I am trying to perform what I believe is a difficult recursion using a CTE is SQL Server 2008. I can't seem to wrap my head around this one. In the below examples you can assume a fixed depth of 3...nothing will ever be lower than that. In real life, the depth is "deeper" but still fixed. In the example I tried to simplify it som...

Token-based server access validation failed with an infrastructure error

I would appreciate help with the following issue: I have created a local group in our SQL 2008 server and added two Windows user accounts "DOMAIN\UserName" I then added the local group to the database and granted read only access. The users are trying to link tables using MS Access using and ODBC connection and getting the following ...

SQL Server statement Where myfield content giving sub-string

Greetings, I'm looking for a SQL Server statement to retrieve records Where myfield content giving sub-string. Thank you, ...

Report Manager doesn't show all options

I've got an instance of SQL Server 2008 Enterprise with Reporting Services installed also. I am hosting and administering this locally. My issue is that when I connect to the Report Manager web application I only get the Home|My Subscriptions|Help menu in the upper right hand corner. I am connecting using Windows Integrated Authentica...

sp_notify_operator: The specified @operator_name does not exist (but it does!)

OK, so I think I'm going mad here! Here's where I am. SQL Server 2008: I've set up Database Mail, and I've sent myself a test email. Simple, works fine. I've created an operator, called 'Tom'. I've given it an email address (but nothing else). However, when I run this command: EXECUTE msdb.dbo.sp_notify_operator @name=N'Tom',@subj...

How to return values from a dynamic SQL Stored Procedure to the Entity Framework?

I have a Stored Procedure which executes some dynamic SQL. I want to use this Stored Procedure in entity framework 4, but when I try to create a complex type the procedure returns no columns. Is there any way I can force it to return my values and get the entity framework to receive them? Here is a much-simplified example of what I want ...

Why should one use Common Table Expressions?

Hello, I just read this link http://msdn.microsoft.com/en-us/library/ms186243.aspx Here is the code to create table and insert data :- -- Create an Employee table. CREATE TABLE dbo.MyEmployees ( EmployeeID smallint NOT NULL, FirstName nvarchar(30) NOT NULL, LastName nvarchar(40) NOT NULL, Title nvarchar(50) NOT NULL,...

How can I migrate schema and data from Access 2000 to Sql Server 2008?

Title says it all. I want to copy the data from an existing Access 2000 database to an existing Sql Server 2008 database. I would prefer to have the ability to only copy some data, so that I may add constraints (like ON CASCADE DELETE) as I go. Any ideas? ...

Nested Create Type in Stored Procedure Declaration T-SQL

I am writing a SQL Stored Proc which takes in a single table valued parameter. Is it possible for me to create the table type in the parameter definition, for example: CREATE PROCEDURE example ( @param (CREATE TYPE tableparameter ( column1 int, colunn2 varchar.... )) READONLY ) ...

What's the best way to copy a millions rows from one sql server database to another?

I have one database that gets a million rows added to it on a daily basis. Every day I'd like to run a query to pull out the million oldest rows(leaving about ten million in the database), and then move them into an archive database. There are well documented ways of doing this with sql server(bcp, openrowset, etc), but from what I can ...

Is there an equivalent method to sp_generateinserts for SQL Server 2008?

In SQL Server 2005, there was a stored procedure available called sp_generateinserts. However in SQL Server 2008, it doesn't seem to exist. Does anyone know if it is still around? Thanks. ...

How to export query result to .csv file in SQL Server 2008 ?

How to export query result to .csv file in SQL Server 2008 ? Thanks in advance ...

Change name of stored procedure in SQL Server 2008

I have a stored procedure which I edit through Visual Studio 2008. Is there a simple way to change the name of the stored procedure? Right now if I look at the sproc's properties, the name of the sproc is grayed out. ...

Add Unique Index on Union View (SQL Server 2008)

I have a view which combines two tables using UNION ALL. Is it possible to create a unique index on the view? ...

Using SQL Server Fulltext Search with a Union View

Hello, I have a view which combines two tables via UNION ALL. The view is also schemabound, if that matters (WITH SCHEMABINDING). Is it possible to enable fulltext search on this view? I understand that Fulltext Search requires a unique index, but I can't create it because of UNION. Is there another way to make Fulltext Search work on...

View or User Defined Function?

I have a scenario where I combine two tables into one (using UNION) and also JOIN data from some other tables. I can do this either with a VIEW or a UDF/User Defined Function. Considering that I have no view so far at all in my database, but quite a few UDF's for fulltext search and the like, I'm tempted to use a UDF for this scenari...