sql-server

Updating a Table from a Stored Procedure

I am trying to learn database on my own; all of your comments are appreciated. I have the following table. CREATE TABLE AccountTable ( AccountId INT IDENTITY(100,1) PRIMARY KEY, FirstName NVARCHAR(50) NULL, LastName NVARCHAR(50) NULL, Street NVARCHAR(50) NULL, StateId INT REFERENCES STATETABLE(StateId) NOT NULL ) ...

Microsoft.SqlServer.SqlTools.VSIntegration reference problem/oddities in Visual Studio 2010

SQL Server Edition: 2008 Enterprise Visual Studio: 2010 w/ .NET 4.0 SSMS 2008 Addin - Data Scripter project source code on CodePlex references Microsoft.SqlServer.SqlTools.VSIntegration.dll I have referenced the DLL under <<Microsoft SQL Server install location>>\100\Tools\Binn\VSShell\Common7\IDE But here is the oddity. Microsoft.S...

Combine two tables that have no common fields

I want to learn how to combine two db tables which have no fields in common. I've checked UNION but MSDN says : The following are basic rules for combining the result sets of two queries by using UNION: The number and the order of the columns must be the same in all queries. The data types must be compatible. But I hav...

how can I Update top 100 records in sql server

Hi Guys, I want to update Top 100 records in sql server . I have a table T1 with fields F1 and F2. T1 has 200 records. I want to update F1 field of Top 100 records. How can i can update in sql server. Thanks Rajesh ...

deleting databases in sql server

I need to delete databases whose name start with "In"... I Tried "Like" but it is throwing syntax errors... I tried following command but throwing syntax errors for "name" SELECT 'DROP DATABASE ' + name + ';' from sys.databases where name like 'In%' ...

How to integrate open ID Login

I want to integrate Open ID, Google and Yahoo login in my site, So please anyone can tell me the process of integration in ASP.NET. ...

How can I do a Cascading Delete with the SQL 2008 HierarchyID data type?

I haven't used the HierarchyID much, so I'm a little unsure. If my table has a HierarchyID, how do I perform a cascading delete? (i.e. delete all 'children' when deleting the 'parent') I assume I would have to use a CTE and HierarchyID functions, but not sure how to go about it... ...

How to check if there is a table in sql server or not using c# code?

I like to write c# code through which i like to check whether there is a table or not in sqlserver? can any one give me a sample code for that? ...

Web interface for an existing WinForms/SQL Server application, data access

Hi, I'd like to get some suggestions about the following scenario. I have a WinForms application which connects to a SQL Sever 2005 (Express) database hosted in a server located in the same LAN than the clients. Now I need to provide a web interface for intranet/internet usage. I think that the Intranet part won't be a problem because ...

A T-SQL query executes in 15s on sql 2005, but hangs in SSRS (no changes)?

When I execute a T-SQL query it executes in 15s on sql 2005. SSRS was working fine until yesterday. I had to crash it after 30min. I made no changes to anything in SSRS. Any ideas? Where do I start looking? ...

I want ip address of sql server while copying data using a stored procedure

I have a job which has a stored procedure that copies data from one server to another.But problem is that there are two servers,in one i've to copy data in batch of 50 and other in the batch of 10.So,i need to check ip addresses in that case ...

What are the different ways of handling 'Enumerations' in SQL server?

We currently define a list of constants (mostly these correspond to enumerations we have defined in the business layer) at the top of a stored procedure like so: DECLARE @COLOR_RED INT = 1 DECLARE @COLOR_GREEN INT = 2 DECLARE @COLOR_BLUE INT = 3 But these often get repeated for many stored procedures so there is a lot of duplication. ...

how to set the query timeout from SQL connection string

i want to set the querytimeout fromt he connection string. not the connection timeout , is it possible? ...

SQL Query :Change to improve execution time

I have 2 Tables . CategoryMaster(CATEGORY_ID (primaryKey),Category_Name) and FILE_MASTER (FileId primaryKey,FILE_TITLE,FILE_DESCRIPTION,CATEGORY_ID (refer to Category Id of category master)) Now I want to have an SQL query which will return a resultset with 2 columns : Categories and the number of Files created under the category. I ...

Using UDFs in Entity Framework

Is it possible to use user-defined functions (UDFs) in Entity Framework? Would it be possible to use them through stored procedures and then add them to the model? As far as I know it's only possible to use select stored procedures through Function Imports if they return an entity - correct me if I'm wrong ;-) ...

And/or keyword when search with ASP.NET

I'm now writing a searching application on C#/ASP.NET. User inputs a keyword into a textbox, and then my app finds appropriate results from SQL Server through ADO.NET. I want to implement ability to search using AND/OR keyword in my application. For example: Now my users can input a keyword such as "Cisco". Now they want to search ...

Looking for resources to learn SQL Server

I'm very new to SQL Server. I got a task from my boss where it involves SQL Server. He gave me a little introduction about it but I would like to know if there are other ways on how to deal with it. I have a little background on Access but not that so intensive. I would like to ask your opinion, where to start if you're dealing with S...

Stored Procedures vs No Stored Procedures - Security Viewpoint

For a web application database, from a security standpoint only, what are arguments counter to the point for an sp only solution where the app db account has no rights to tables and views and only exec on sps? If someone intercepts the app db account, the surface area exposed to an attack is much less then when tables and views aren't e...

SQL JOIN vs IN performance?

I have a case where using a JOIN or an IN will give me the correct results... Which typically has better performance and why? How much does it depend on what database server you are running? (FYI I am using MSSQL) Thanks ...

Convert web-based CMS to support utf-8

I have to support an outdated CMS, which has some parts written in ASP, some in PHP and uses SQL Server for back end. Virtually anything in that system is written with two supported input languages in mind- Latvian and English. Therefore, it uses windows-1257 encoding in all web pages, that use that CMS, and also all admin pages. In data...