sql-server

Can I ensure the order of dialog conversations in sql service broker?

So, I've got an 'A' server and a 'B' server. We are using SQL Service Broker to perform replication. An application we have will need to write data to either the 'A' server, or the 'B' server. (one may be down, and the other one should take over) Data is written to the database only within stored procedures, which are wrapped in a ...

ASP dynamic URLs from SQL Server database

Hey everyone, I have a database which contains my product info, which you can see connected to a catalog page here: http://www.marioplanet.com/catalog.asp I would like now, to have product pages created, with the URLs being generated by a certain name in my database. For example, if you point your browser to the link above, and look a...

SQL 2005 - two tables Join on some id,

Let's say I have 2 tables. I want join them so that for every account I get 1 row where the account's information is there PLUS the primaryContact's information appended to the table. Is this possible? ID's are unique keys. ACCOUNT TABLE accountid | name | income | primaryContact 123456789 Jack Johnson 1...

SQL Error on Audit Trail Insert after Scope_Identity()

I'm trying to use a stored procedure to do an insert on a main table, then also insert that data into a historical data table. I don't want to use a trigger, but rather just do a simple insert of all columns into the history table. I am getting this error, however. "An explicit value for the identity column in table 'ipaudittrail' can...

Nesting sql queries inside case

Hi guys, I am trying to write a SQL query where I am joining two tables and retrieving a few columns. Once this is done, based on a two fields (source table enum, id in the corresponding source table), I need to retrieve a value matching the id in the source table. The issue is that I cannot join all the source tables, and want to do ...

sql server computed column from other table

Possible Duplicate: formula for computed column based on different table's column Hi, does anyone know how to make a computed column with taking the value from another table? thanks ...

How to insert into sql server Many to many relationship tables

I imported data into csv table via .net app, pls help, how can i aInsert into all the tables so that i can query; student avg score to a question or test student answers to a question or answer frequency to a question etc My tables are in this form; Csv Ans Quest Test Ans_Quest_Test --------- ------ ...

SQL Server minus MySQL Features

Hi, I know MySQL and and trying to learn SQL Server . I am looking for features/keywords that are in SQL Server and not in MySQL. Eg: TOP, CLUSTERED/NONCLUSTERED Indexes etc.. Any links/pointers are appreciated. Thanks! ...

How to deny delete on a table for all users

Within SQL Server 2005, is there a way, with a single statement, to deny delete on rows in a particular table for all users of the database? ...

How can I add an integer from another table to the current selected table in SQL Server?

Does anyone know how can I add an integer from another table to the current selected table in SQL Server? For example: I have 2 tables with the following information in each table tableA: id username point status country 1 alvin 1 1 U.S.A 2 alvin 1 1 U.S.A 3 amy 1 ...

Temporary tables and transactions in sql 2005

I write app in c#. I use temporary tables inside transaction. My server is sql 2005. Is there any performance threat, I read somewhere that using temporary tables inside transactions should be avoided ( http://www.sql-server-performance.com/tips/temp_table_tuning_p1.aspx post at the bottom of the screen added at 2-24-2003 ). ...

SQL Querying for two Consecutive Rows

I have the following query: SELECT year_week FROM web_details where location = ''JF'' AND property_id = ''FARM'' which produces the following results. YEAR_WEEK 201035 201036 201037 201039 201041 201044 201045 201048 What I actually want is to produce a set of results which only displays values if the consecutive value is available...

SQL Server Exception "A severe error occurred on the current command. The results, if any, should be discarded"

Hi All, Can somebody help me get through the following Sql Exception : "A severe error occurred on the current command. The results, if any, should be discarded". I'm running a drop replication (i.e sp_dropsubscription & sp_droparticle) script reading from the uploaded file using c#.net. I encounter the above error when running in Sq...

Code to generate SQL Server table schema from ADO.NET

I'd quite like to use ADO.NET to generate a CREATE TABLE script to create an exact copy of a given table. The reason for this is persistence testing. I would like to know whether my application will persist to a particular database. I would like to be able to point the app to the database and table in question, and then the app will gen...

How do I select a regex match from a text/varchar in MS SQL?

I need to extract something from a long piece of text across lots of db rows, in a Microsoft SQL Server database. I could write a script to loop through and extract it, but I was hoping there was nice simple way I can do some SQL like: SELECT IpAddress = matchFirst('RegEx',ColName) FROM table WHERE conditions I've looked about but a...

TSQL Bulk Insert

Hi all, I have such csv file, fields delimiter is ,. My csv files are very big, and I need to import it to a SQL Server table. The process must be automated, and it is not one time job. So I use Bulk Insert to insert such csv files. But today I received a csvfile that has such row 1,12312312,HOME ,"House, Gregory",P,NULL,NULL,NULL,...

SQL - displaying row where the next numeric value is also available

I have the following query: SELECT CAST(year_week AS NUMERIC) as year_week FROM web_details where location = ''JF'' AND property_id = ''FARM'' which produces the following results. YEAR_WEEK 201035 201036 201037 201039 201041 201044 201045 201048 What I actually want is to produce a set of results which only displays values if the...

SQL Server: procedure don't output anything?

I'm trying to create a stored procedure which will fetch data from sys.databases and sys.database_files and combine this information into a single result set. Here's the code CREATE PROCEDURE dbo.PROC_getDbInfo AS SET NOCOUNT ON GO TRUNCATE TABLE dbo.dbinfo GO EXECUTE sp_msforeachdb 'insert into dbo.dbinfo ...

Classic ASP ADODB with SQL Server Compact Edition 3.5 is not working in Command Parameters

Hi All, I'm new to SQL CE. I'm programming in Classic ASP, connecting the SQL CE using ADODB.Connection. I have created the table and trying to insert data from the ASP. I tried in 3 ways. The inline insert statement [e.g. INSERT INTO tblName(col1, col2) VALUES(1,2)] (WORKED) The parameterized insert statement [e.g. INSERT INTO tblNam...

How do you join a query between 2 databases involving sys tables?

-- find last usage info, -- how far back this information goes depends on the -- server/database settings select -- ss.name as SchemaName, so.name as SprocName ,so.create_date as SprocCreated, so.modify_date as SprocModified ,so.object_id ,stat.last_user_seek,stat.last_user_scan,stat.last_user_lookup,stat.last_user_update ,stat.last_...