sql-server-2008

How to backup SQL Server 2008 database - only the objects, without data

How to backup SQL Server 2008 database - only the objects, without data thanks in advance ...

SQL Server Express 2008 not detaching auto-attached file?

The MSDN documentation for SQLEXPRESS says: When an application first establishes a connection from a running instance of SQL Server Express, SQL Server Express will automatically attach an .mdf file. When the user closes the application, SQL Server Express detaches the .mdf file from the instance. This does not appear to be happe...

SQL Server Latches and their indication of performance issues

I am trying to understand a potential performance issue with our database (SQL 2008) and in particular one performance counter, SQLServer:Latches\Total Latch Wait Time Total Latch Wait Time (ms). We are seeing a slow down in DB response times and the only correlating spike that I can match it with is a spike in Total Latch Wait Time and ...

Tracking sql agent Job changes - SQL Server 2008

Hey all - situation: Need track/audit changes in SQL jobs - to be reported in scom for example. SQL job exists job is changed (changed/scheduled/enabled/disabled, etc) Needed: trigger to check for this. Anyone out there already written one? Many thanks, Tom ...

Disk Space Issue Installing SQL2008 SP1

I'm trying to install SQL 2008 SP1 on our SQL2008 server. This server has very little disk space available on the C drive. SQL 2008 is installed on the D drive. I only have about 1.5GB available space on C. I downloaded SP1 to the D drive, I installed from the D drive, and YET, the installer runs my C drive out of space. I started lookin...

Query regarding SQL Insert in SQL Server?

I am using SQL Server 2008 and developing a project which is in maintenance phase. I want to insert record in a table whose primary key is an Integer but not an identity. e.g. table name is tblFiles and fields are ID, FileName, FileContent. Actually that table is in use so I don’t want to make any schema change in it. And I want the ...

SQL authentication in SQL Server 2008

I have this problem. I first connect(log) to SQL Server using SQL Management Studio the authentication is set to Windows Authentication. Then I go to the Security => Logins folder and add a user, the authentication is: SQL Server authentication, I give him also the sysadmin role [all roles] I try to login as that user, but I can't I...

Most efficient way to select records in one database based on result set from totally different database

I have 2 totally separate databases - one MSSQL and one Pervasive. Due to the way our product data is stored in the Pervasive database, you cannot easily run a query to get a products's information and features to display on our website. So, using a DTS package I take the product data from Pervasive and process it so it is one MSSQL t...

Will SQL 2008 query opmtimizer optimize this query?

Have I to break this query SELECT ISNULL(SUM(AF.[amount]), 0) AS [firm], ISNULL(SUM(ACA.[amount]), 0) AS [cash], ISNULL(SUM(AC.[amount]), 0) AS [client], ISNULL(SUM(AFR.[amount]), 0) AS [fr], ISNULL((SUM(AF.[amount]) + SUM(ACA.[amount]) - (SUM(AC.[amount]) + SUM(AFR.[amount])), 0) AS [total] FROM ... into two: DECLARE ...

Some questions about HierarchyId (SQL Server 2008)

I am a newbie in SQL Server 2008 and just got introduced to HierarchyId's. I am learning from SQL Server 2008 - HIERARCHYID - PART I. So basically I am following the article line by line and while practicing in SSMS I found that for every ChildId some hexadecimal values are generated like 0x,0x58,0x5AC0 etc. My questions are What a...

SQL Server 2008: Can a multi-statement UDF return a UDT?

Is it possible that a multi-statement UDF return a User Defined Table Type, instead of a table that is defined within it's return param? So instead of: CREATE FUNCTION MyFunc ( @p1 int, @p2 char ) RETURNS @SomeVar TABLE ( c1 int ) AS I would like to do: CREATE FUNCTION MyFunc ( @p1 int, @p2 char ) RETURNS @SomeVar M...

How to escape ? character in jdbc stored procedure calls

Hi, I would like to call this stored procedure with jdbc: sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" JDBC thinks the ? is a placeholder for an argument. In fact it is used by the SP to put in the table name. How can I call the stored procedure? I tried this: CallableStatement call = jdbcConnection.prepareCall("call sp_m...

Why do I get an Arithmetic overflow error converting numeric to data type numeric in ADO.NET?

Original Question: Why do I get an Arithmetic overflow error converting numeric to data type numeric in ADO.NET code using the Money Data Type when amount is greater than $999,999,99? Just as the question says... I have a bit of ADO.net code in the data access layer that talks to a Sql Server 2008 database. There is an Amount column...

Using sql date data type and EF4

I have a table w/ a sql date data type. When I look at the EDM markup, the storage element reflects this. The conceptual entity has a data type of DateTime (there doesn't appear to be a Date data type). When I call save changes and have a DateTime instance associated w/ the entity I want to persist, I get the following error: The conver...

How to write a query for SQL Server 2008 that returns the dependencies of an object (Exactly what Management Studio shows with the "View Dependencies" menu)

Management Studio connected to SQL Server 2008 Right click on an object and choose "View Dependencies" Now you can navigate through de dependendies back and forth. How do I get the same information programmatically? (an SQL query?) ...

Adding collected errors to database

I have an application that monitors a process and "learns" exceptions, by adding them to a DB. The process to gather the errors/exceptions is pretty solid, but not the storing on the DB side. What I want to accomplish is something like public int GetErrorId(string StringToClassify) { sql = "SELECT [id] FROM [DBNAME].[dbo].[ERRORS] WHER...

Returning from a stored procedure before it is finished executing

We have a stored procedure in which there are two parts. In part 1, failures need to be returned to the application, and the part must be completely executed before the stored procedure returns. Part 2 is a long process which needs to execute whenever the procedure is called, but all failures can be ignored (or handled elsewhere), howe...

Free Schema Export for SQL Server 2008?

Not sure if this belongs here or on ServerFault, but I wonder if someone knows a free tool to export a SQL Server 2008 Schema? It's only for Tables and their Indexes, Foreign-Keys etc. and it needs to be a command line tool to run as part of a build process. If it can read a .net connection string, that would be awesome (hence the .net t...

Thread safe sql transaction, how to lock a specific row during a transaction ?

I have a procedure like this: create procedure Checkout @Foo nvarchar(20), @cost float as begin transaction declare @Bar nvarchar(20); select @Bar = Bar from oFoo where Foo = @Foo; update Foo set gold = gold - @cost where name = @Foo; update Bar set gold = gold + @cost where name = @Bar; delete from oFoo where @Foo = Foo; commit tra...

Showing ident_current("tbluser") but not able to see current id'd data..

Hi guys, I am using sql server 2008 which is communicating to java web service which is communicationg to asp.net application. I have written stored procedure as follows: create procedure abc(@intA int,@intB int,@intOutputParameter int output) as begin insert into tbluser(A,B) values (@intA,@intB) /*where B is fo...