sql-server

Sql Compact and __sysobjects

I have some SQL Compact queries that create tables inside of transaction. This is mainly because I need to simulate temporary tables, which SQL Compact does not support. I do this by creating a real table, and then dropping it at the end of the transaction. This mostly works. Sometimes, however, when creating the tables Sql Compact will...

How to write a calculation query in SQL?

Using SQL Server 2000 My Query. SELECT (Format(IIf(CLng(OutTime) > 180000, CDate('18:00:00'), CDate(Format(OutTime, '00:00:00'))) - IIf(CLng(InTime) < 90000, CDate('09:00:00'), CDate(Format(InTime, '00:00:00'))), 'hh:nn:ss')) As WorkTime, (Format(IIf(CLng(InTime) < 90000, CDate('09:00:00') - CDate(Format(InTime, '00:00:00')), ...

NHibernate bug sql generator

i have class named Group i tried to test configuration: var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof (Group).Assembly); new SchemaExport(cfg).Execute(true, true, false); when i debug this, im getting following sql: create table Group ( ID INT IDENTITY NOT NULL, Name NVARCHAR(255) null, ...

Loop in trigger SQL Server

I have below trigger ALTER TRIGGER [dbo].[DeleteUserData] ON [dbo].[site_users] AFTER DELETE AS BEGIN SET NOCOUNT ON; --delete user uploads update my_gallery set deleted=1 where un=(select un from deleted) and subdomain=(select subdomain from deleted) --delete user pms delete from pms where toUn=(select un from deleted) and subdomai...

Datatype for storing ip address in SQL Server

What datatype should i choose for storing an Ip Address in a SQL Server? By selecting the right datatype would it be easy enough to filter by IP address then? ...

What is the best way to fast insert SQL data and dependant rows?

Hi, I need to write some code to insert around 3 million rows of data. At the same time I need to insert the same number of companion rows. I.e. schema looks like this: Item - Id - Title Property - Id - FK_Item - Value My first attempt was something vaguely like this: BaseDataContext db = new BaseDataContext(); foreach (...

Extract data from SQL Server database

Hiya all, I've connected to database, using data set .xsr now I wan't to extract all rows in my table. Here is my table structure : Lastname Address zipcode city country email So here is one example of table row entry : Danish Morten Olsen 58b 82341 Kobenhavn Denmark [email protected] Now I'd like for someone to tell me how can I ext...

Moving ms access driven site from sql server to jabry.com - connection string problems

Hi, I've done a fair bit of mysql php programming but am pretty new to asp/access etc. This will either be incredibly easy or impossible! SUMMARY: I'm trying to transfer a web application from a corporate network to an external web host for testing and don't know how to connect the pages to the database on the new server. BACKGROUND...

Damerau-Levenshtein distance for words

I am looking for such an algorithm, but one that makes substitutions between words and not between letters. Is there such an algorithm? I am looking for an implementation with SQL Server, but the name of the algorithm will be good enough. ...

SQL Server recursive CTE and paging

I have this table CREATE TABLE [dbo].[friend_blocked_list]( [subdomain] [varchar](50) NOT NULL, [un] [nvarchar](50) NOT NULL, [friend] [nvarchar](50) NOT NULL, [is_blocked] [bit] NOT NULL, [approved] [bit] NOT NULL) where i select data from it with below query. Select query combines users that added user as friend and users that...

Linq to SQL, SQL Server 2008 and optimization

I'm designing a large scale web application with about 30 tables, more than 2/3 of which are related to each other. I'm using ASP.NET MVC, Linq to SQL with SQL Server 2008. These tables are meant to hold thousands of records. As a programmer, what should I focus on to help optimize the database and the queries to and from Linq? Do you...

difference of date in sql and php

how can calculate (now) - (date in database) ...

When I Insert Rows into a SQL Server 2005 Table will the order be preserved?

When I select a series of rows from a sql server 2005 table using an "order by" clause and then insert them into a different (and empty) sql server 2005 table can I count on the rows staying in the same order. The reason I am asking is that I want to manipulate the rows using ADO.net. I want the rows in a specific order to improve th...

Automate Importing Multiple Excel Worksheets into SQL

In VB6: I need to allow a user to select an Excel file, and then upload All Worksheets to a SQL table. I'm not sure how to do this. The format of each sheet is exactly the same. And the worksheet format matches the SQL table format. I'm really banging my head against the wall over here. If anybody could offer a suggestion, or a cod...

Logging SQL Errors

SQL Server 2008 has a new try/catch structure. If I encounter an error in a sequence of nested stored procedures, I like to log the call stack in an error table. The problem is that if I have started a transaction (which will be true for operations that update the db), an records written to the error table will be removed when the code...

How do I use AXSD in SQL Server?

In SQL Server you can use an XML datatype and map it to relational columns using an AXSD schema. Mapping between XML and relational storage By using an annotated schema (AXSD), the XML is decomposed into columns in one or more tables. This preserves fidelity of the data at the relational level. As a result, the hierarchi...

How to check whether the job is disabled or Not in sqlserver management studio 2005??

As part of the holiday processing some of the jobs are disabled in sql server using script. They are not disabled manually. Now when we see the jobs there is a check mark for enable entity. And when we right click on the job the instead of enable thing being highlighted disable entity is highlighted. Now we are getting doubt whether job...

How to display all the record by date wise?

Using SQL Server 2000 Table PersonID Date 001 11-02-2009 002 11-02-2009 003 11-02-2009 001 12-02-2009 004 12-02-2009 005 12-02-2009 003 13-02-2009 005 13-02-2009 So on…, I want to display all the Personid by Date wise. Expected Output PersonID Date 001 11-02-2009 002 11-02-2009 003 11-02-2009 004 11-02-2009 005 11-02-2009 001 ...

Cross tab query with boolean fields as row headers.

I currently have a table structure that looks something like this(some details omitted): ColumnName || Type Date_Of_Job DateTime Reparied_Service Boolean Disconnect_Service Boolean Relayed_Service Boolean Reparied_Stopcock Boolean Replaced_Stopcock Boolean TPFNR_Repaired ...

Postfix term in SQL Server Full Text Search

At MSDN I read: < prefix_term > Specifies a match of words or phrases beginning with the specified text. Enclose a prefix term in double quotation marks ("") and add an asterisk (*) before the ending quotation mark, so that all text starting with the simple term specified before the asterisk is matched. Well, tha...