sql-server-2005

mirroring state of the database went to disconnected state in SQL Server 2008

I have 4 databases mirrored using High Protection mode without witness server between two servers(principal and mirror) that are in the same domain. Manual failover worked fine for several days. But later somehow the IP of the principal server was changed in the DNS, then onwards the mirror state of these databses went to disconneted sta...

How to get the list of tables and their columns in a databse which are having a specific keyword in their name

I have to make a list of tables and their columns that are having keyword 'EMP' in their column name. The database is having around 160 tables. Is there any way of finding this quick ? ...

Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

HERE IS A QUERY select IssueNo, KendraCode, IssueTime, DateOfIssue, P_MotaBags, P_MotaWeight, P_PatlaBags, P_PatlaWeight, P_SarnaBags, P_SarnaWeight, NewBags,OldBags, TransporterName, TruckNumber, DriverName, TruckOwner,SocietyCode , (SELECT PaddyMotaW, PaddyPatlaW, PaddySarnaW, BagsMota, BagsPatla, BagsSarna,PC_ID, sangrahankendraid...

Selecting Nested Xml Elements using FOR XML - Best Practice

I am working on retrieving data in Xml format from SQL Server 05 using FOR XML What is the best practice for nesting elements in my resulting Xml? Currently I am doing this: Select ( Select [Col1] As [Col1], [Col2] As [Col2] From [dbo].[NestedTable] As T1 Where T0.[Key] = T1.[Key] ...

Non localized \ language independent sql formatting

Hi All, Is there a way in sql 2005 to have non localized formatting. For eg. 1,234.567 (FLOAT) in English is 1 234,567 (FLOAT) in Norwegian. So if an English client sends a FLOAT number to Norwegian server, it gets rejected. Is there a way to format types like floats and dates etc. in a way which is not language\localization specific?...

SQL Join to only 1 row - SQL Server 2005

Hi I have an AllocatedStock table holding a case number (knows as a TPND) and a quantity. I need to select a list of product stock but present this with the product number (known as TPNB) rather than the case number. I also have a ProductLookup table which holds all TPNBs and TPNDs. AllocatedStock AllocatedStockID identity TPND int ...

SQL Server 2005 Error 701 - out of memory

I'm currently having following error message when executing a .sql file with about 26MB on SQL Server 2005: Msg 701, Level 17, State 123 There is insufficient system memory to run this query. I'm working with 4GB RAM, 64Bit Windows 7 Ultimate, Core2Duo T6400(2GHz)... Is there a way to execute it without receiving this message (maybe ...

"Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'." to SQL Server 2005

I'm trying to migrate a legacy application we have to Windows Server 2008 x64 and IIS7. It's written in Classic ASP and connects to a SQL Server 2005 database. However, when the page runs, I receive the error: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. The connection string I'm...

SQL Server 2005 (Express) - Login vs User

I'm quite new to Microsoft SQL Server. I have some experience with MySQL, and there you have a user with priviliges, if I understand things right; these priviliges decide which databases you have access to on the MySQL server. However now I am in the situation where I have to restore a database on my SQL Server 2005 Express, and this da...

Change a Primary Key from Nonclustered to Clustered

Suppose I have an SQL Server 2005 table, TableX, with 2 indexes on it: PK_TableX = PRIMARY KEY NONCLUSTERED on FieldA IX_TableX_FieldB = CLUSTERED on FieldB I want to switch the PK to be CLUSTERED, and the other index to be NONCLUSTERED. I have to assume that the database will be in use at the moment I try to change the indexes round...

SQL caching strategy

I'm working on an interactive contact search page (contacts are returned via ajax as you type or select criteria). I want this page to be very responsive. There is a complex set of rules to determine which contact records a given contact can see; these rules are rolled up into a user-defined function, DirectoryContactsByContact(@Contac...

SQL Server 2005/2008 - Import a fixed width text file via the command line?

In MySQL I am able to create a table with fixed column widths and then can use the load data infile command to import a fixed width file. For example: Fixed width text file = JOHN 1234 Imports into table: Username - CHAR(8) Password - ChAR(4) The beauty of this approach is that the file is 'chopped' up based on the column size...

Built-in database role in SQL Server 2005 to permit execution of stored procedures?

In SQL Server 2005, there are built in roles: db_reader db_writer etc. Is there any role that lets a user execute an stored proc? I don't want to use db_owner, because that will permit deletion and updates, which I don't need. The only permissions I need are: SELECT EXECUTE ...

Replace null character in a string in sql

I need to replace a null character in a sql string, i cant seem to find the right command to achieve this. I have used replace (myString ,'\0', '') but this seems not to work, any help would be great ...

Could someone please explain OVER

I have borrowed a query and adapted it for my own purposes, but I don't like doing this when I am not entirely sure what it is doing. SQL docs are less than descriptive on this clause. Here is what I borrowed and modified, can you tell me what it is doing basically? (SELECT Id FROM ( SELECT Id ,RAN...

Does Sql Server Compress Database size on similar data

Hi all, Just to find out my would be DB size on production environment, I just populated my tables with 1.5 million rows of nearly same data (Except Primary key). It currently shows 261 MB... Now, Whether I can rely on this, or since the Data is almost similar on all other columns the SQL server has compressed the size. ie. Will the...

Problems calling a Stored Procedure from VB.NET

As you can probably very soon see, I am a complete newbie at VB.NET, and I am having some trouble getting output from a stored procedure in SQL Server 2005. This is the code I use Dim con As New SqlConnection Dim cmd As New SqlCommand("esp_getDates", con) Dim par As New SqlParameter("@PlaceID", SqlDbType.Int, 3906) con....

How to automate a Visual Studio/SQL Server report

I'm currently working on a reporting tool for a company that conducts the same survey at different clients. So the analysis and report would be the same, except for the conclusions. The ultimate goal of the project would be a tool that automatically extracts, analyses the data and creates the report. SQL Server and Visual Studio are mand...

Auto increment keyword in sql 2005

I need to know what keyword v should use for autoincrement in the table with primary key in sql 2005 ...

Storing Multibyte in SQL Server

What should be the data type in SQL Server to store multibyte characters ? NVARCHAR or VARCHAR ...