sql-server

Creating SQL Server 2000 database using SQL Server 2008.

My development machine has SQL Server 2008 Developer edition on it. A production server I am going to do some development for has SQL Server 2000 on it. Is there a way to create a 2000 database using my 2008 developer edition? Or do I need to create it on the 2000 server and move it to my development machine? ...

SQL Server - can't do COUNT on DATEDIFF without doing CREATE VIEW

Hi, I am trying to get some information on the differences in two dates and how often that difference has occurred. I can use: SELECT DATEDIFF (day, db1.dbo.t1.Date1, db2.dbo.t2.Date2) AS Days FROM db1.dbo.t1 JOIN db2.dbo.t2 ON db1.dbo.t1.wID = db2.dbo.t2.cID AND db1.dbo.t1.Action LIKE 'Standard' ...

stored procedure error handling

i have this procedure for inserting rows in tables(sql server 2005) CREATE PROCEDURE ans_insert ( @q_desc varchar(2000), @sub_id int, @marks int, @ans1 varchar(1000), @ans varchar(1000), @userid varchar(15), @cr_date datetime ) AS BEGIN BEGIN TRY BEGIN TRANSACTION DECLARE @q_i...

Cannot create SSPI context

Hi All, I am working on a .NET application where I am trying to build the database scripts. While building the project, I am getting an error "Cannot create SSPI context.". This error is shown in the output window (inside VS2008 screen) and the building process failed. Please help on this. SQL Server is configured to work on Windows aut...

SQL Server 2008 CTE And CONTAINSTABLE Statement - Why the error?

I am testing out moving our database from SQL Server 2005 to 2008. We use CTE's for paging. When using full-text CONTAINSTABLE, the CTE will not run and generates an error. Here's my non-working code- WITH results AS ( SELECT ROW_NUMBER() over (ORDER BY GBU.CreateDate DESC ) as rowNum, GBU.UserID, NULL AS DistanceInMi...

deploy SQL Server Express database with desktop app?

I've created my first database based desktop app in .NET and not able to understand how can I deploy the database with the application installer, so that the database, application and the SQL Server is installed in one go. If I only deploy the native client for SQL Server and the database with the installer, will it work? The applicati...

Asp.net session state server with SQL Server

We're trying to get session state working using the following web.config line: <sessionState mode="SQLServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="Data Source=dbServer;User ID=stateUser;Password='thepassword'" cookieless="false" timeout="20"/> On dbServer, we've run the following ...

Trying to convert "yy/mm/dd hh:mm:ss" (stored as char) into datetime using computed column

Hi. This seems like it should be simple but it's driving me up the wall. I have two columns - 'tx_date' and 'time' stored each as char(10). (bad database design I know, but wasn't my design) From a query I can convert them into a datetime just fine - "...convert(datetime,tx_date,time,11)..." (so tx_date "09/11/27" and time "07:12:...

Parse and Import XML into Table in SQL Server

Hi I've written a CLR assembly that exports a table's data to an XML file. Now I want to import this data into a temp table on another instance. The XML file structure is like this: <row> <SystemInformationID>1</SystemInformationID> <Database_x0020_Version>10.00.80404.00</Database_x0020_Version> <VersionDate>2008-04-04T00:00:00</V...

How to Insert Records based on the Previous Insert?

Here's my procedure: PROCEDURE add_values AS BEGIN INSERT INTO TABLE_A ... SELECT t.id, t.name FROM TABLE_C ("This selection will return multiple records") END While it inserts in TableA, I would like insert into another table(TableB) for that particular record which got inserted in tableA. The columns in TableA and TableB ar...

Intellisense and code formatting T-SQL for SQL Server 2008 in Visual Studio 2008?

I'm looking for a Visual Studio 2008 add-in / plug-in that can provide Intellisense and flexible code formatting for T-SQL for use with SQL Server 2008. It needs to work with Team System Data Edition ("data dude"). I am familiar with the Red Gate tools, but they do much more than I needwhich unfortunately puts the price on the high sid...

Need very simple 'sequence' for GetNextOrderNumber for SQL Server

I'm trying to make an even simpler function than the one described here to get the next value of an order number for a shopping cart. I don't care if there are gaps Only completed orders get an ID (i.e. I'm deliberately not using IDENTITY) Obviously there must not be duplicates I don't care about performance and locking. If we have so ...

SQL Query using distinct

hello i have a table with the following structure: sku, category, brand, product_name, inventory_count with the following data: 1001, car, honda, "honda car 1", 5 1002, truck, honda, "honda truck 1", 6 1003, car, ford, "ford car 1", 7 1004, truck, ford, "ford truck 1", 8 1005, bike, honda, "honda bike 5", 9 1006, bike, ford, "ford bi...

SQL query getting data

In SQL Server 2000: hello i have a table with the following structure: sku brand product_name inventory_count ------ ------ ------------- --------------- c001 honda honda car 1 3 t002 honda honda truck 1 6 c003 ford ford car 1 7 t004 ford ford truck 1 ...

How can I see the data of a SQL server database in c#, and where it's store?

Hello, I have a program written in c# visual studio 2008 with SQL server 2005 (.mdf) database. Here is part of the code: ... SqlCommandBuilder cb; cb = new SqlCommandBuilder(dataAdapter); String[] dataList =new String [8]; ... DataTable resultTable = new DataTable(); ...

sql server 2005 .mdf .ldf files

I have those 2 files (.MDF and .LDF) how could i attach them to microsoft sql server in order to see their content ? ...

Specify PK name during table creation

In MSSQL is there a way to specify a name for a PK constraint so that MSSQL doesn't provide a randomly generated PK name like so: PK__Addresse__3214EC074E88ABD4 The only way I can see to do it now is to first create the table and then issue an ALTER command to rename the PK. It would be easier if I could do it in one shot. ...

SQL Server 2008 spatial index and CPU utilization with MapGuide Open Source 2.1

I have a SQL Server table with hundreds of thousands of geometry type parcels. I have made indexes on them trying different combinations of density and objects per cell settings. So far I'm settiling for LOW, LOW, MEDIUM, MEDIUM and 16 objects per cell and I made a SP that sets the bounding box according to the extents of the entities in...

What is meant by 'House Keeping' in context of a database ?

One of my clients has mentioned the term 'Database House Keeping' in his tender specs. I am not sure about the term, please help. ...

SQL Server: How to order by date, if the date is < GetDate()

Hi, Here's an interesting one... hope I can explain it well... I have a collection of competitions in a single table in my SQL Server DB. I'm doing a full text search over them, which works fine. However, some of the competitions are closed, and I want these closed comps to show up after the open comps, while still respecting the rank ...