sql-server

Formatting IPv6 as an int in C# and storing it in SQL Server

Under IPv4 I have been parsing the string representation of IP addresses to Int32's and storing them as int's in SQL Server. Now with IPv6 I'm trying to find out if there's a standard or accepted way to parse the string representation of IPv6 to two Int64's using C#? Also how are people storing those values in SQL Server? As 2 fields of...

SQL Server 2000 drop column with constraints

I have the same problem as described in this question, but there it's SQL Server 2005 and the "accepted" answer doesn't work in SQL Server 2000. Specifically: I'm trying to run ALTER TABLE foo DROP COLUMN bar, and it's failing because there's a "default constraint." Meaning, I have a default value on that column which SQL Server implem...

SQL Server - Query Performance on Table Lookup

I have a database where I need to query to get records from one table and then lookup on another table to see if that value exists there. That table might return multiple records and I want the one with the most recent date. So table 1 is basically: ID (Primary Key) Name Test_Score And Table 2 is Test_Id (Primary) Student_ID (Forei...

NHibernate and sql timestamp columns as version

Hi, I've been racking my head trying to get Nhibernate to work with a byte array as version mapping to an sql timestamp. I'd implemented an IUserVersionType but Nhibernate was creating varbinary in the database rather than timestamp. Inspired by a blog post by Ayende recently on concurrency, I changed my mapping to specify the sql-type t...

How to check if I'm currently the database owner for SQL 2000/2005/2008

I can't remember how to do this in a TSQL query. It was a one-liner, good for testing before running DML. The query was something similar to SELECT IS_DBO() or SELECT IS(DBO). ...

Table - Edit Mode (Sql 2008)

In Object Explorer you can right click on a table and select Edit Top 200 Rows. When you do it opens the table in Edit Mode. Does anyone know the syntax of how to write that in a query so you do not have to right click and select Edit Top 200 Rows? Thanks ...

Validate MSSQL identifier (parameter) in .NET or regular expression

In a .NET project I need to verify if a string is a valid Microsoft SQL Server 2005 parameter identifier. Example: SELECT * FROM table WHERE column = @parameter Is there a runtime class method to validate a string for being a parameter, or is there a regular expression that verifies the rules? (see below) From the documentation on ide...

Handling hashed passwords stored as varbinary in SQL Server and classic ASP

All, Sorry in advance - I'm a novice in most of the topics below (SQL, ASP). Anyway... I've got a pretty simple web app that requires users to log in with a user name and password. The front end creates a salted SHA1 hash of the password, and posts it (along with the user's name) to an ASP page. That ASP page takes the data, calls a...

Virtualize the database server or the web server?

In a web application architecture with 1 app server (IIS) and 1 database server (MSSQL), if you had to pick one server to virtualize in a VM, which would it be: web or db? Generally speaking of course. ...

Show Group Above Details Query

Data in Table : ItemCode ItemName ItemGroup SFD Softdrink NULL CCL Coco Cola SFD FNT Fanta SFD SPR Sprite SFD ACL Alchol TQL Tequila ACL VDK Vodka ACL When user find "Softdrink" then the result will be: ...

Can anyone recommend a tool for generating a simple C# ASP.Net Web Application for a SQL Server database?

I have a SQL Server 2005 database which holds a fairly basic schema. I'm fine with accessing it through Management Studio, but I need to be able to provide read-write access to other internal staff so they can modify the contents of certain tables. Can anyone recommend a tool (preferably free) that can look at a SQL Server database and...

What's the best way to search a DB table using a stored procedure?

Dear All, I want to know what's the best way to search a DB table using a stored procedure (let's say text search)? What are the points I should look at? Let me know if you guys want more information. ...

SQL Server Database standards & best Practices

Are any SQL Server Database standards & best Practices documentation that I can use as reference for naming conventions, security, using schemas, etc? ...

SQL full-text-search

I have set up the full-text search functionality in SQL Server 2008 express. This is what I did: -- STEP 1: Create catalog create fulltext catalog HtmlSearch -- STEP 2: Fill catalog create fulltext index on docs (WordHtml) key index IX_docs_1 on HtmlSearch with change_tracking auto -- STEP 3: Search select * from docs where freetext(*...

Weird SQL Server query problem

So I have this weird problem with an SQL Server stored procedure. Basically I have this long and complex procedure. Something like this: SELECT Table1.col1, Table2.col2, col3 FROM Table1 INNER JOIN Table2 Table2 INNER JOIN Table3 ----------------------- ----------------------- (Lots more joins) WHERE Table1.Col1 = db...

How to compare the structure of two MS SQL databases?

I need a free tool or some kind of tip/technique to compare the structure of two Microsoft SQL databases. Preferably MS SQL 2005. The technique I tried to make work was generating scripts from both databases and then comparing the two files but SQL Server generates object in random order. ...

SSIS mismatched Join

I have two sets of data which I need to join, but there is an added problem because the data quality is not great. The two data sets are Calls (phone calls) and Communications (records created about phone calls). They have ID's called call_id and comm_id respectively. The communication records also have call_ids to perform the join. The...

single quotes(') Insert problem in sql server 2005 stored procedure

txtname.Text.Trim().Replace("'", "' + char(39) + '") the above statement is not working for stored procedure ...

SQL Server - inconsistent behavior when reading uncommitted changes of the same transaction

Working with SQL server with isolation level "read committed snapshot", we routinely write data to the database and read it further on in the context of the same transaction. Usually when reading from the database we see our own uncommitted changes but only committed changes made by others. We assumed that this is the expected behavior ....

Insert NULL and DEFAULT values with an INSERT/SELECT statement

Hi, In MICROSOFT SQL SERVER have the following table: CREATE TABLE [T1] ( [ID] int IDENTITY (1, 1) NOT NULL, [col1] int NOT NULL, [col2] int NOT NULL, [col3] int NULL, [col4] datetime NOT NULL DEFAULT (getdate()), [col5] datetime NOT NULL DEFAULT (getdate()) ) I want to write an insert statement that select 2 columns from anothe...