sql-server

SQLRT TESTCONNECTION 2 returns 1 -What could be possible problem

Hello all , I am using this function SQLRTTESTCONNECTION2() to connect to SQL server. Its returning me as value 1 ,which means failure to establish a connection. What could be possible cause for this?Any ideas please? ...

How to use ORDER BY, LOWER .. in SQL SERVER 2008 with non-unicode data

Hi, The question is about Armenian. I'm using sql server 2005, collation SQL_Latin1_General_CP1_CI_AS, data mostly is in Armenian and we can't use unicode. I tested on ms sql 2008 with a windows collation for armenian language ( Cyrillic_General_100_ ), I have found here, ( http://msdn.microsoft.com/en-us/library/ms188046.aspx ) but ...

SqlCommand - preventing stored proc call in other databases

When using SqlCommand to call a stored proc via RPC, it looks like it is possible to call a stored proc in a database other than the current database. e.g. : string storedProcName = "SomeOtherDatabase.dbo.SomeStoredProc"; SqlCommand cmd = new SqlCommand(storedProcName); cmd.CommandType = CommandType.StoredProcedure; I'd like to m...

writing an Dynamic query in sqlserver

hi, DECLARE @sqlCommand varchar(1000) DECLARE @columnList varchar(75) DECLARE @city varchar(75) DECLARE @region varchar(75) SET @columnList = 'first_name, last_name, city' SET @city = '''London''' SET @region = '''South''' SET @sqlCommand = 'SELECT ' + @columnList + ' FROM dbo.employee WHERE City = ' + @city and 'region = '+@region --...

How can we handle concurrency errors in LINQ to SQL?

How can we handle concurrency errors in LINQ to SQL? ...

Single Query returning me 4 tables, How to get all of them back into dataset ?

How to fill multiple tables in a dataset. I m using a query that returns me four tables. At the frontend I am trying to fill all the four resultant table into dataset. Here is my Query. Query is not complete. But it is just a refrence for my Ques Select * from tblxyz compute sum(col1) suppose this query returns more than one table...

Database design for credit based purchases

I need an elegant way to implement credit-based purchases for an online store with a small variety of products which can be purchased using virtual credit or real currency. Alternatively, products could only be priced in credits. Previous work I have implemented credit-based purchasing before using different product types (eg. Credit, ...

Sub-Schemas in SQL Server 2005/2008

This is a simple question yet I was unable to find any information at all about this. Is it possible to have sub-schemas in SQL Server 2005/2008? Example: Having a HR (Human Resources) schema with a sub-schema called Training (with tables related to this). It would end up like HR.Training.* where * would be the tables. ...

cross tab query

Hi guys, I have a project table with the following columns ProjectID, ProjectDescription and a list data table which has the following columns ProjectID ListType Date Memo Every project has many list type entries in the ListType Table. What I want to do is run a query which will return something like this ProjectID, ProjectDescri...

How to call SQL Function with multiple parameters from C# web page

I have an MS SQL function that is called with the following syntax: SELECT Field1, COUNT(*) AS RecordCount FROM GetDecileTable('WHERE ClientID = 7 AND LocationName = ''Default'' ', 10) The first parameter passes a specific WHERE clause that is used by the function for one of the internal queries. When I call this function in the fron...

Which DBCC commands do I need to run to make sure SQL Server's caches are totally clean?

I want to do some SQL Server performance testing and I want to establish a good baseline. I want to flush all the caches each time so that I know between each test it hasn't cached something so it performs better in between runs. Which DBCC commands should I use to make my SQL server as clean as possible? ...

syscomments table uses multiple rows. Why?

I was writing a script that kept giving me errors. After tracking it down I found that the syscomments table stores its contents in multiple rows if the information gets to long past varchar(8000) i believe. Why does the syscomments table break the data up into multiple rows instead of 1 single larger row? performance? ...

Optimal storage of data structure for fast lookup and persistence

Scenario I have the following methods: public void AddItemSecurity(int itemId, int[] userIds) public int[] GetValidItemIds(int userId) Initially I'm thinking storage on the form: itemId -> userId, userId, userId and userId -> itemId, itemId, itemId AddItemSecurity is based on how I get data from a third party API, GetValidItemI...

Modeling a Generic Relationship (expressed in C#) in a Database

This is most likely one for all you sexy DBAs out there: How would I effieciently model a relational database whereby I have a field in an "Event" table which defines a "SportType"? This "SportsType" field can hold a link to different sports tables E.g. "FootballEvent", "RubgyEvent", "CricketEvent" and "F1 Event". Each of these Sp...

Is there a standard practice for synchronizing SQL Server tables?

I've written an application that retrieves pricing and part options from a SQL database to generate a 3D Model of the product and create a sales proposal. My client likes it so much they want to be able to use it on laptops in the field now. The catch is, they won't have an internet connection. I'm considering setting up a SQLite data...

What is the suggested approach to Syncing/Backing up/Restoring from SQL Server 2008 to SQL Server 2005

I only have SQL Server 2008 (Dev Edition) on my development machine I only have SQL Server 2005 available with my hosting company (and I don't have direct connection access to this database) I'm just wondering what the best approach is for: Getting the initlal DB Structure & Data into production. And keeping any structural changes/da...

VB6 to SQL SERVER

hi, am new in SQL programming.. and am using SQL 2000. my main problem is to connect the server to another PC running a VB6. pls help me. ...

SQL:Placing Column values in variables using single query

In SQL server,How can i place the value of more than one column in variables using one query Ex : My query is : SELECT ET.ID,ET.Description,ET.DefaultTemplateText FROM TBL_EMAILTEMPLATE ET WHERE ET.NAME='OneWeekReminder' I want to place the Column values in variables. Thanks in advance for the help ...

SQL Server 2005 Fail: Return Dates As Strings

Hello all, I am using the SQL Server PHP Driver, I think this question can be answered without knowing what this is. I have come across this many times, what does it mean by NAMES? Column names?: SET NAMES utf8 Is there a query similar to the above that will get my dates to be returned as a string? For some reason on my SQL Sever 20...

Correct escaping of delimited identifers in SQL Server without using QUOTENAME

Is there anything else that the code must do to sanitize identifiers (table, view, column) other than to wrap them in double quotation marks and "double up" double quotation marks present in the identifier name? References would be appreciated. I have inherited a code base that has a custom object-relational mapping (ORM) system. SQL ...