sql-server

SQL Server 2008 - Default column value - should i use null or empty string?

For some time i'm debating if i should leave columns which i don't know if data will be passed in and set the value to empty string ('') or just allow null. i would like to hear what is the recommended practice here. if it makes a difference, i'm using c# as the consuming application. ...

Automatic Database Synchronisation

Hi all, I am using SQL Server 2008 and Visual Studio 2008 I have two databases.I need to run a query in a database and grab those results and update a table inside another database. This process would be done every one hour automatically. How can I do it? Data Transmission Services(DTS) used from SQL 2000? Is there something better t...

How Can we implement MARS kind of functionality in SQL Server 2000

Previously i working on SQL Server 2005 and i used MARS functionality but currently i am working on a old project and they want SQL Server 2000 as a backend.. and i want MARS kind of functionality in it.. please tell me how can i do this.. frontend is (VB.NET) ...

SQL Server creating a temporary table from another table

I am looking to create a temporary table which is used as an intermediate table while compiling a report. For a bit of background I am porting a VB 6 app to .net To create the table I can use... SELECT TOP 0 * INTO #temp_copy FROM temp; This creates an empty copy of temp, But it doesn't create a primary key Is there a way to crea...

Update SQL Server from GridView with a Checkbox

Hi all There is a GridView with a Checkbox field on the page. And there is a button on the same page. There is a field which is related to the checkbox in the sql. Is there any simple way to update the sql? Not row by row. Best Regards, ...

Using Stored Procedure for reading records from Database in NHibernate?

Hi, Is reading the database records from the Database using Stored Procedures in NHibernate a good approach?If yes then why or if No, then also why? The application has only the feature of reading values from the database using NHibernate in the data access layer no updates and no inserts just only retrieval. ...

Database Table Normalisation

We are storing the metadata of the content in the database tables. Out which there is a column named keywords which contains the keywords related to the content. So, should we normalise the table based on the keyword column because the keyword column will be holding multiple values. ...

Determine that a database is currently mirroring or not?

Is there a T-SQL script to determine a database is currently mirroring or not? Is there a way to determine its partner? Thank you very much. ...

Gridview Refresh Problem

Hi there, I have a gridview in an asp.net page, and get the data by binding it to a SQL Server Table, I use C# and Stored Procedure in SQL server to bind the data. every thing works fine,except when I Delete multiple rows by using Stored Procedure, the gridview still shows the old data. actually I have couple of text boxes that the user...

"Insufficient System Memory" Error in SQL Server 2008

I get the following error in SQL Server 2008: There is insufficient system memory in resource pool 'internal' to run this query. I recently migrated from SQL Server 2000 to SQL Server 2008, and the system is Windows Server 2K8. ...

How to get other than numerics in a string(removing numerics in strings) in sqlserver

how to truncate the numerics in a string in sqlserver ForEx: String value: 200 May not be[34534] Result: Many not be (reulst contains other than numerics) ...

Select Count(Distinct Value) returns 1

I'm designing a query in SSMS 2005 which looks something like this: SELECT COUNT(DISTINCT ColumnName) FROM Table WHERE ColumnName IS NOT NULL When I run the query with COUNT() it returns the value 1. When I run it without COUNT(), SSMS reports the correct value eg 212 records. The column in question is of datatype numeric(16, 0). Fo...

How to separate the string value and create temp to store separate string in temp table

I am using SQL Server 2005. I have created a table with the columns ID and Courses. Records are as follows: ID      Courses 1.      Java, ASP.Net, C# 2.      Java 3.      Java, C# 4.      html The Courses column is of type varchar and the values in it are comma separated. I want to separate every word and store it in another or temp. ...

Getting data from SQL Server (serverside) to JavaScript (clientside)

I have been looking for good newbie-advice on how to efficiently read data from an SQL Server to use in a JavaScript based timeline. Please consider that I have never done anything like this before. I have basic oop knowledge and would like to use json, I have written small java apps, but never used javascript (although I suppose it won'...

Programmatically getting SQL Cluster Virtual Name

I have written a Windows service to collect information from all of our SQL servers. The service gets installed onto each server, and utilizing WMI and SMO, inserts relevant system information back to a central database. In order to get the SQL information, I use the following c# code: List<Server> sqlServers = new List<Server...

Is there a tool for refactoring SQL, a bit like a ReSharper for SQL

The sort of stuff I'm after right now is quite basic: Auto format Detect ununsed variables Variable naming convention checking I wouldn't be surprised if there was a tool available that could handle more complex refactorings such as those found in Refactoring Databases, but I appreciate that the added complexities introduced by curr...

How do I get a proper weighted average date in SQL

I use this query to get my average date: CONVERT(DATETIME, AVG(CONVERT(FLOAT, ChargeOffDate))) as [Average C/O Date] Which correctly give me the date '2003-08-12 14:17:22.103'. When I use this query to get the weighted average date CONVERT(DATETIME, SUM(CONVERT(FLOAT, ChargeOffDate) * FaceValue) / SUM(FaceValue)) I get a date like...

multiple parameterized sql-statements in ado.net on SQL Server

I have a problem executing two parameterized questions in one batch using SqlCommand in ADO.NET. (I want to reduce round-trips and avoid pinging) Since I don't want execution plan pollution I expect ADO.NET to transform my CommandText from "stmt1; stmt2" with all parameters belonging to stmt1 and stmt2 added to SqlCommand.Parameters t...

How do I query an XML field in SQL Server 2005 so that it behaves like a table?

I have a table that contains a user_id, and an XML field containing basically a series of values. I need to run a report against the data in the XML, but for the life of me I cannot get the XML out of the field in any useful fashion. Here's the schema for the table: |-----------------| | type | name | |-----------------| | int | ...

Django <-> SQL Server 2005, text encoding problem

Hello, I'm trying to store Django data on MS SQL Server 2005 using: http://code.google.com/p/django-pyodbc/ (pyodbc + FreeTDS) As long as I'm storing string consist of ASCII characters everything is ok. When I'm using unicode (ex. '\xc5\x82'), django throws ProgrammingError on: ProgrammingError at /admin/cli/punktrejestracji/add/ ('4...