sql-server

If the base table underlying a view is restructured, eg. attributes are added, does the application code accessing the view need to be redone?

If the base table underlying a view is restructured, eg. attributes are added, does the application code accessing the view need to be redone? ...

Alternative to having an aggregate concatenation function

I have the following tables in SQL Server 2005 ReceiptPoint: ID (PK), Name GasIndexLocation: Location (PK) ReceiptPointIndexLocation: ReceiptPointId (FK), IndexLocation (FK), StartDate, EndDate On any given day, a ReceiptPoint can be mapped to 1 or more IndexLocations. I need to be able to, for a given day, see what IndexLocatio...

How do I suppress T-SQL warnings when running a script SQL Server 2005?

Is it possible to suppress warnings generated by T-SQL scripts? If so, how? I know I can turn of the 'records affected' messages with SET NOCOUNT ON but is there an equivalent for warnings? Eg: Warning: Null value is eliminated by an aggregate or other SET operation. If I'm expecting these errors, it helps to sift the real errors ...

Set start value for column with autoincrement

Hi I'm using MS Sql Server. I have a table like this: [Orders] Id | SubTotal | Tax | Shipping | DateCreated The Id column is set to autoincrement(1,1). This is to be used in an E-commerce storefront. Sometimes a current E-commerce store is migrated to my platform and they already have Orders - which could mean that their current Ord...

How to specify guest access to C#/SQL internet site?

I just created a website in ASP.NET and C# and am hosting it now at this URL below. This URL is working now: http://96.0.101.66/Default.aspx However, currently this website does not list the SQL tables, which should be on the left-hand side of this window in a gridview. I think this is because I disabled anonymous access from IIS...

port number of SQL Server

Hello everyone, I am wondering what ports are used by SQL Server database engine? I need such port number to write configuration scripts to grant access to specific port of the machine installed with SQL Server to make it safe. A related question is whether SQL Server database engine will use one static port number to serve all client r...

Convert DateTime to DateTime that works with SQL Server?

I am trying to add some dates to some asp.net membership fields (LastLoginDate, LastPasswordChangedDate, etc) so what I did was DateTime sendDate = new DateTime(1754, 1, 1, 12, 0, 0); then I tired to use linq to sql and add them. It comes back with an exception "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/...

mysql to mssql conversion with OPENROWSET

I saw couple of tools but all are paid, I have only one database in MySQL that we want to convert in MSSQL. Suppose i create the schema by myself then is it possible to use OPENROWSET to open connection to mysql and import all data into sql with following statement? INSERT INTO Customers SELECT * FROM ( OPENROWSET ( 'm...

How can I return only one resultset from a pivot query in sql server?

Hello, I have the following T-SQL Pivot query. SELECT AccountNumber, EventID, CreateDate, [ITEMBOOK] AS ITEMBOOK, [POSTER] AS POSTER FROM (SELECT ProductID, Quantity, EventID,AccountNumber,CreateDate FROM #tmpStartupItems) ps PIVOT ( SUM (Quantity) FOR ProductID IN ( [ITEMBOOK], [POSTER]) ) A...

LinqToSql "in" clause

Is there an equivalent of SQL's IN clause, in LinqToSql? For example, how would the following query be done in LinqToSql: select * from users left join groups on groups.pkid in (select group_id from user_group where user_group.userid = users.userid) ...

Identifying accurate matches from SQL Server Full Text Search

Hello I am using SQL Server 2008 Full Text Search, and joining to the FreeTextTable to determine ranking of results. How do I determine whether the result set is giving an accurate match or not? For example, for one search I may get these results: Manufacturer | Rank =================== LG U300 ------- 102 LG C1100 ------ 54 LG GT50...

How to integrate MSDN Library, SQL Server Books Online, and Windows SDK Help?

The Short Version: I want a single, comprehensive MSDN Library, up-to-date and integrated with F1 help in all Microsoft development tools. The Long Version: There are at least three products that want to install documentation on my workstation: Visual Studio 2008 wants to install MSDN Library. SQL Server 2008 wants to install Books ...

Primary Keys in Oracle and SQL Server

What's the best practice for handling primary keys using an ORM over Oracle or SQL Server? Oracle - Should I use a sequence and a trigger or let the ORM handle this? Or is there some other way ? SQL Server - Should I use the identifier data type or somehow else ? ...

Determine varchar content in nvarchar columns

I have a bunch of NVARCHAR columns which I suspect contain perfectly storable data in VARCHAR columns. However I can't just go and change the columns' type into VARCHAR and hope for the best, I need to do some sort of check. I want to do the conversion because the data is static (it won't change in the future) and the columns are indexe...

Database save, restore and copy

An application runs training sessions. Environment for each session (like "mission" or "level" in games) is stored in a database. Before starting a session, user can choose which of many available databases to use. During the session database may be modified. After the session changed database is usually discarded, but sometimes may b...

SQL Server Schema Syncronization

I am working on a pre-existing MS SQL Server database that was not designed very well. Indexes and primary keys were missing in most cases. There were NO foreign key constraints. I made a local copy of the DB (so as not to work on the live version), and fixed most of the problems. I now want to syncronize my changes to the productio...

PreparedStatement is executed on prepareStatement on SQL Server

We have a Java code similar to the following: PreparedStatement stmt = connection.prepareStatement("drop login tmp"); int result = stmt.executeUpdate(); When running through a debugger, it seems that our SQL statement is executed after the first line is executed, and even before the second line is executed. When the second line is exe...

C# SQL parent child table select query help

Hello, I have two tables that I want to fetch data from. Lets call them "Parent" and "Children". The "Parent" table has many records in the "Children" table. (One to Many) My problem is I want to find an efficient method for displaying the data the two tables contain to my ASP.NET MVC application. My approach is to select all records ...

Can this SQL be translated to LINQ?

Hi, I am working with a quite tricky SQL-Query that I would like to translate to LINQ. Do you think it is possible? WITH ConditionalChecks AS ( SELECT c.ItemId FROM ConditionalProperties c, Properties p WHERE c.PropertyId = p.Id AND c.IsChecked = 1 AND ( (p.SystemName = 'eatable') OR (p.SystemName = 'diy') ) ), ...

Synchronize access to static variables in sql server SQLCLR

I have written an assembly which is integrated in sql server, providing some stored procedures written in C#. The assembly has a readonly static variable holding some configuration data. This data is manipulated via stored procedures, which are also provided by the assembly. Obviously I have to synchronize access to this static variable....