sql-server

how do you go about dealing with ajax and Model Binding when complex types are involved?

I would like to keep model binding when doing ajax calls from my view. I'm using jquery ajax to make the calls, and just as an example- this is my controller method I want to call from ajax: public ActionResult Create(Person personToCreate) { //Create person here } As you can see, this method is relying on Model Binding. This make...

best way to convert and validate a date string

I have a single char(8) variable formatted as ddmmyyyy in a stored procedure (quality and validity of this value is unknown and beyond my control). What is the best most efficient way to move the value into a datetime variable, and throw an error if it is not valid datetime. DECLARE @Source char(8) DECLARE @Destination datetime ...

Ambiguous column name error, how do I fix it?

1. Users 4 Cols UserID - UserName - RealName - Flags 2. UsersGroups 2 Cols UserID - GroupID 3. Groups 3 Cols GroupID - GroupName - Flags What I want to do is select a specific UserName ie USERA and update the Flags column. but I also want to update the Flags column in the Groups table to the same value. UPDATE dbo.Users SET Flags = ...

LFL sales query in SQL

This might seem a bit like a do-my-homework-for-me question (and it is), but I think that the sales results I’m trying to get are fairly generic and will be useful for anyone doing sales reporting. I have a basic Sales table (fields: Branch, DateOfSale, SalesAmount) in SQL Server 2005 and I need to build a report with the data in that t...

Detect Sql Express From TSQL

Hi, I need a safe (i.e consistent, robust) way of detecting whether or not the sql server I'm accessing is Sql Express. I think I'd prefer to be able to do this from TSQL, since I already have a connection string and all the libraries I need to execute TSQL (this should help avoid issues with whether or not WMI is installed/running, the...

functional reason why stored procedures don't support INSERT/EXECUTE INTO?

In SQL Server, there's no way to create a temp table on the fly from the results of a stored procedure, ala: CREATE TABLE #temptable AS EXEC spMyStoredProc or EXEC spMyStoredProc INTO #temptable or something like that. Instead, you have to know the SP layout beforehand, and have to do something like this: CREATE TABLE #temptable (...

Fastest SQL Server protocol?

What is the fastest SQL Server connection protocol? Related: which protocols are available remote versus local, and does that affect the choice of fastest protocol? ...

Providing a "user-friendly" interface to fulltext search

We use SQL Server fulltext search for several tables on our application. We always use AND searches, e.g.: "Evil" returns "Evil Dead" and "The Evil of Fu Manchu" "Evil Fu" returns only "The Evil of Fu Manchu" We want to keep the interface down to just a single search box and button, and we don't want people to have to learn much (if ...

How to Ignore "Duplicate Key" error in T-SQL (SQL Server)

I have a transaction that contains multiple SQL Statements (INSERT, UPDATE and/or DELETES). When executing, I want to ignore Duplicate Error statements and continue onto the next statement. What's the best way of doing that? Thanks in Advance. ...

what does one to one table mapping mean?

I heard this phrase when I was listening to dot net rocks this morning. apparently linq to sql only supports one to one table mapping. ...

What are the ramifications of granting a DB User with limited access Execute permission?

If I have a user that only has limited permissions - just db_datareader and db_datawriter, which should only permit the user to query data and insert/edit/delete data, without allowing the user to add/modify/delete tables in the database. There may be a need for the user to be able to execute stored procedures. If the user is given exe...

When should I use Cross Apply over Inner Join?

What is the main purpose of using CROSS APPLY? I have read (vaguely, through posts on the Internet) that cross apply can be more efficient when selecting over large data sets if you are partitioning. (Paging comes to mind) I also know that CROSS APPLY doesn't require a UDF as the right-table. In most INNER JOIN queries (one-to-many re...

Real-time query execution plans while debugging a T-SQL script

I have SQL Server 2008 and SSMS 2008, and I'm debugging a script. I can step through the script with no problems at all, but if I click the toolbar button for "Include Actual Execution Plan" (the one that adds an additional results tab with the execution plan), I'm not able to debug anymore. Instead, when I click debug, debugging starts...

SQL Server Query for Rank (RowNumber) and Groupings

I have a table that has some columns: User, Category, Value And I want to make a query that will give me a ranking, of all the users by the value, but reset for the category. Example: user1 CategoryA 10 user2 CategoryA 11 user3 CategoryA 9 user4 CategoryB 3 user1 CategoryB 11 the query would return: Rank User Category ...

Classic ASP problem connecting to remote SQL Server database

I have a classic ASP app that I am trying to connect to a SQL Server 2008 database on a different server. The ASP app is being served from IIS7 on Windows Server 2008. I have changed the web site's application pool to run under a specific windows account, that I have verified has access to the database on the remote server. However, wh...

How can I determine which of my SQL 2005 statistics are unused?

After a few years, one of my largest databases has accumulated 73 statistics on one of it's largest tables. With indexes, I can run many types of reports and queries to decide how often / heavily specific indexes are used. Is there an equivalent for statistics? How can I tell which ones are useless after all these years? We're running ...

How to check existence of a sql server object and drop it?

EDIT: the function creation was missing, sorry about that I have a T-SQL request that goes: DECLARE @IsSomething bit SET @IsSomething = 0 IF /some tests/ SET @IsSomething = 1 EXEC(' CREATE FUNCTION IsSomething () RETURNS bit AS BEGIN RETURN ' + @IsSomething + ' END') Of course if I run it twice I get There is already an object ...

SQL Server conection not working, Please help!

hi, I'm not very good at deployment and I'm facing a problem: First Off, I'm using Vista. i have created a windows application in vb.net which has a database file named Customerdb.mdf in it. I have selected the database and in the property, I have selected Embedded Resource option. I have used the following connection: Dim con...

Count total rows with a group by

I have the following query: select count(ords.TRACKING_NUM) from Orders ords (NoLock) group by ords.TRACKING_NUM having count(distinct ords.ORDER_NUM) = 4 I want it to retrieve the total amount of TRACKING_NUMs that have 4 ORDER_NUMs on them (should be 3,352). Instead I get 3,352 rows equal to 4 (or more because of the distinc...

DTS Packages Empty

When trying to edit a package the server doesnt display package contents. When trying to create a new package the Server Explorer shuts down. No error msgs. At the same time I can connect via client tools from a pc and the packages looks fine. Has anyone seen this issue? Rebooting doesnt fix it and the machine has plenty space on all dri...