sql-server

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 ...

Best way to enforce this data-integrity constraint?

I have 3 tables (lets call them Foo, Bar and Baz. Tables: Foo FooId Bar BarId FooId Baz BazId BarId AnotherValue Obviously the foreign keys make it so that each Baz is associated with a Bar, and hence, associated with a Foo. Now I want to ensure that for each set of Baz with the same "AnotherValue" all the associated Foo's ...

adding an exam booking detail to database

how to add an exam booking audit trail to the database, where we can determine when and who has uploaded exam results ...

"Debug"(get information) on a running stored procedure in MS Sql Server

Hello, i aked myself if it is possible in MS SQL-Server 2005 to get information of a running stored procedure. Because meanwhile it is executing for more than 8 hours, i would like to know on what step it is or if it is even actually running at all. MS SSMS says that it is still executing the query. Thanks in advance, Tim ...

Can I use sql bulk copy to copy data within the same server ?

Can I use sql bulk copy to copy data within the same server ? ...

How to reverse values in a string in T-SQL

Using T-SQL, I'm trying to find the easiest way to make: "abc.def.ghi/jkl" become "abc/def/ghi.jkl"? Basically switch the . and / Thank you ...

Deleting a sql server table takes much time

Hi, I have a table which have more than 380 million records.... I have a stored procedure which 1. Delete some records in that 2. Insert something into it. The total procedure takes around 30 minutes to execute. Out of this DELETE takes 28 minutes. Delete is a simple statement -> Delete a where condition_1 AND condition_2 AND c...

Need help for SQL select query for this two table

Table Capture image : http://img844.imageshack.us/img844/6213/99730337.jpg ------------ PositionTable------------ ID ContentFK Position 11 100 1 12 101 1 13 104 2 14 102 2 15 103 2 16 105 3 17 106 3 18 1...

Getting error after installing sql server 08 Express edition

I have installed SQL server 08 express edition and then tried to connect using SQL server management studio, but getting below error: TITLE: Connect to Server Cannot connect to My-PC\SQLSERVER. ------------------------------ ADDITIONAL INFORMATION: A network-related or instance-specific error occurred while establish...

Is there a legitimate reason for using so many varchar fields? (MS SQL DB)

I'm working on data migration from an old IBM Universe-based system to a new enterprise-level data-information management system, and learning about database design in the process. I took a look at the back-end database structure of the new system (it's a MS SQL DB, with about 100 tables), and find some things pretty odd. But I don't k...

Composite Index vs. INCLUDE Covering Index in SQL Server

Hi Folks I understand that Composite Indexes are always used Left to Right (e.g. if an Index was on City, State, WHERE City = "Blah" or WHERE City = "Blah" AND State = "AA" would work fine but WHERE State = "AA" would not). Does this same principle apply to INCLUDE indexes? Thanks in advance! Clay ...

Can I specify the default SQL Server with two named instances installed?

I have SQL 2005 Express installed. I then installed SQL Server 2008 R2 and am running both instances successfully. They are named: COMPUTERNAME\SQLEXPRESS (2005) COMPUTERNAME\INSTALL2 (2008) I am trying to figure out how to specify the 2008 instance as the default server. I have tried: Data Source=.\local; ... Data Source=.; ... Da...

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...

Transferring Data between two SQL Server 2000 Repository.

I need to Extract data from a SQL repository Process It and then save it in 2nd Repository. Nature of data: Transfer selected users data, though the tables are similar in both repository but not same, and some amount of processing needs to be done on the data to be transferred. The volume data is very large 5,00,000. What technique ...

SqlBulkCopy unable to Parse "0", "1" bool values into BIT on database table.

I am using my custom CSVDataReader : IDataReader {} to insert Bulk values in a Database table. Every datatype but the Bit (from "1"/"0") is parsed perfectly. I am getting the following error " value of type String from the data source cannot be converted to type bit" while parsing 0 or 1 as bool If I change these values to "true"/"fal...

Create Sql Database Tables from Business Objects

What is the best way to create Sql Server tables from business objects. For example I'm writing an application that has a user object to store user information. What's the best practice for creating tables from these objects? Create the objects first and then define the database or is there a tool to transform business objects into table...

Conditional SQL ORDER BY ASC/DESC for alpha columns

Writing a stored procedure in MS SQL Server 2008 R2, I want to avoid using DSQL... I would like the sort method (ASC or DESC) to be conditional. Now, with a numeric column I would simply use a case statement and negate the value to emulate ASC or DESC... That is: ... ORDER BY CASE @OrderAscOrDesc WHEN 0 THEN [NumericColumn] ELSE -[Num...

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)? ...

Importing/Pasting Excel data with changing fields into SQL table

I have a table called Animals. I pull data from this table to populate another system. I get Excel data with lists of animals that need to go in the Animals table. The Excel data will also have other identifiers, like Breed, Color, Age, Favorite Toy, Veterinarian, etc. These identifiers will change with each new excel file. Some may...

How can I explore the data in a SQL database, including foreign tables?

I want to know if any tools exist to explore the data in a relational database, and to drill through master-detail relationships. I already know how to view the data in a single table, and I know how to construct SQL queries that JOIN tables. However, to get N-levels deep, I have to write a SQL statement, find the ID of the item I'm in...