sql-server

SQL Server Cursor data as result of stored procedure

Hello, I have a stored procedure DECLARE cursor FOR SELECT [FooData] From [FooTable]; OPEN cursor ; FETCH NEXT FROM cursor INTO @CurrFooData; WHILE @@FETCH_STATUS = 0 BEGIN SELECT @CurrFooData AS FooData; INSERT INTO Bar (BarData) VALUES(@CurrFooData); FETCH NEXT FROM cursor INTO @CurrFooData; END; CLOSE cursor DEALLOCATE curs...

How to Merge two databases in one in SQL Server 2008?

Hi I have 2 PCs, each one of them has SQL Server 2008 installed on it and there is a database with data in it. I need a way that I can move data in my DB from this SQL Server to another one (another PC which has the same DB) move data from one PC to another one - There is one problem, the ID column, because each DB in my 2 PCs has...

Full Text Search in SQL Server 2008 shows wrong display_item for Thai language

I am working with SQL Server 2008. My task is to investigate the issue where FTS cannot find the right result for Thai. First, I have the table which enables the FTS on the column 'ItemName' which is nvarchar. The Catalog is created with the Thai Language. Note that the Thai language is one of the languages that doesn't separate the wor...

How third-party SQL Server backup tools access databases' files for backup?

I'm reading about Red Gate SQL Backup, and I liked the concept of creating a database backup compressed and writing on disk the compressed backup directly without an intermediate SQL Server native backup. And I'm wondering how this type of software make backups. It accesses the database files directly? It uses some sort of SQL Server o...

SQL Server Index cost

I have read that one of the tradeoffs for adding table indexes in SQL Server is the increased cost of insert/update/delete queries to benefit the performance of select queries. I can conceptually understand what happens in the case of an insert because SQL Server has to write entries into each index matching the new rows, but update and...

Cannot open database "test" requested by the login. The login failed. Login failed for user 'xyz\ASPNET'.

I have created a webservice which is saving some data into to db. But i am getting this error Cannot open database "test" requested by the login. The login failed. Login failed for user 'xyz\ASPNET'. my connection string is add name="ConnectionString1" connectionString="Data Source=.\SQLExpress;Initial Catalog=IFItest;Inte...

Membership tables and other tables in one DB or separate?

I have an ASP.NET site with membership tables in a Main_DB for the site. Can I add more tables for the site for other data needed for the site or should that data be in another database? ...

Determining if a SQL Server table is read-only

What's the best way to determine if a given SQL Server table is readonly, either because of account permissions or the database being marked as read-only? ...

SQL Server switch to MySQL/PostgreSQL for startup?

I just checked out the licensing for SQL Server and well...i can't afford it since im funding this project myself. I have been tinkering with MySQL and PostgreSQL a bit the past few weeks and at this point I can't really decide which to go with. MySQL has a large user base and lots of people using it so finding out how to do various item...

Please tell me what is error in my date comparison sql query

Please help me to find out error in my SQL query. I have created this query to compare dates select * from Joinplans jp where cast(convert(varchar,GETDATE(),103) AS datetime) BETWEEN CASE(convert(varchar,jp.planstartDate,103) AS datetime) AND CASE(convert(varchar,DATEADD(DAY,jp.planDays,jp.planstartDate),103) AS DATETIME) ...

Continuation - Viewing FIRST_ROWS before query completes.

I have identified the query constructs my users normally use. Would it make sense for me to create composite indexes to support those constructs and provide FIRST_ROWS capability? If I migrate from SE to IDS, I will lose the ability to write low-level functions with C-ISAM calls, but gain FIRST_ROWS along with other goodies like: SET-RE...

how to get external variable value in dtsx package.

Hi, I am executing .dtsx package from c#, it was executing fine, if i am passing one variable value from c# code then how can i get it on .dtsx package for my ole db source query. Here is my c# code. string file = @"D:\CYNCZFuzzy\CYNCZFuzzy\Contact.dtsx"; package = app.LoadPackage(file, null); Variable...

Select proper columns from JOIN statement

I have two tables: table1, table2. Table1 has 10 columns, table2 has 2 columns. SELECT * FROM table1 AS T1 INNER JOIN table2 AS T2 ON T1.ID = T2.ID I want to select all columns from table1 and only 1 column from table2. Is it possible to do that without enumerating all columns from table1 ? ...

Calling sp and Performance strategy.

Hi I find my self in a situation where I have to choose between either creating a new sp in database and create the middle layer code. so loose some precious development time. also the procedure is likely to contain some joins. Or use two already existing sp(s), the problem of this approach is that I am doing two round trips to databas...

What is the mysql equivalent of Sql Server's @@Identity and @@error and how to use try catch in mysql

I am looking for few global variable in mysql which are equivalent of sql server. I want the whole list eg. Sql Server Equivalent @@error --- @@Identity --- etc. Basically right now I want to know what are the equivalent variable of @@error and @@identity. But it will be helpfull if u could provide some other variable ...

MSDN about stored procedure default return value

Hello, Could anyone point exactly where MSDN says thet every user stored procedure returns 0 by default if no error happens? In other words, could I be sure that example code given below when being a stored procedure IF someStatement BEGIN RETURN 1 END should always return zero if someStatement is false and no error occurs? I know...

How to escape special characters when retrieving data from database?

I am going to generate XML file based on the data returned from SQL Server, but there are some special characters like  and  (there may be other characters like these), which will fail the XML. Is there any way to escape them? Thanks! ...

SQL Server Service Broker Service Disappearing (Automatically Deleted)?

I've implemented a messaging system over SQL Server Service Broker. It is working great, with the sole exception that every once in a while (maybe once per week per server) my initiator service just vanishes without a trace. The corresponding queue is still there, but the service is missing. Obviously this causes problems in my system...

SQL Job: CmdExec with Multiple Arguments

Is it possible to specify two arguments to CmdExec in SQL JOb Step? I have MyApp.exe Para1 Para2 but it only recognize para1. ...

can't attach .mdf into sql server management

Why can't I browse deeper into the folder, I still have some folders there: ...