sql

Joining on a common table, how do you get a FULL OUTER JOIN to expand on another table?

I've scoured StackOverflow and Google for an answer to this problem. I'm trying to create a Microsot SQL Server 2008 view. Not a stored procedure. Not a function. Just a query (i.e. a view). I have three tables. The first table defines a common key, let's say "CompanyID". The other two tables have a sometimes-common field, let's say "...

SQL cast datetime

In SQL Server 2005, why does: PRINT Cast('' AS datetime) display: Jan 1 1900 12:00AM I would have thought it should be null? ...

trying to figure out how to send multiple file attachments with sp_send_dbmail

MSSQL 2008 Maybe i'm just looking in the wrong place. Here's the scenario: We have files stored in a varbinary(max) column. I'd like to select these as individual files, along with the names of the files stored nearby, as individual file attachments. can this be done? it's easy enough to send the results of a query as an attachment, ...

Online Collaborative Schema Design (leverage google docs?)

I'm looking for an online, collaborative database schema designer. App is for MySQL specifically, but generic DB designer is fine too. It's important that it can handle revisions (history of changes). This looks cool, and I could host it on a server - but doesn't look like it would handle multi-user: http://ondras.zarovi.cz/sql/demo/ ...

How to find definition of predefined code in Oracle 9i?

I am using Oracle 9i and want to know to the definition(code) of predefined functions in Oracle like,REVERSE(),REPLACE(). Is there any library of oracle where i can serach these library functions! Please Suggest!! ...

sp_xml_preparedocument

How to process xml string into store procedure? any help? I don't find sp_xml_preparedocument procedure in sql server 2008... Any input? ...

Compound IDENTITY column in SQL SERVER 2008

An Orders table has a CustomerId column and an OrderId column. For certain reasons it's important that an order's id is no longer than 2-bytes. There will be several million orders in total, which makes 2-bytes not enough for a global order id. A customer will have no more than several thousand orders making 2-bytes enough. The obviou...

Is there a way to find out the user that submitted a SQL query?

I am interested in writing a trigger that would ignore queries from a specific SQL user but take action on all others. Is there any way to do this? A note, though: the user will need to do some queries, so I will need to allow some queries/deletes/etc. ...

Save XML File using LINQ to SQL on XML Field

Hi, i have a SQL Data Base. On this DB i have a Table with a XML Field. I wan to save a XML file on the XML Field using LINQ to SQL. It is possible? Thanks. Sorry for my poor english ...

SQL SELECT across two tables

Hi there, I am a little confused as to how to approach this SQL query. I have two tables (equal number of records), and I would like to return a column with which is the division between the two. In other words, here is my not-working-correctly query: SELECT( (SELECT v FROM Table1) / (SELECT DotProduct FROM Table2) ); How would I do...

sql 2008 metadata modified date

Is there a way to identify the timestamp when an object(table/view/stored proc...) was modified ? there's a refdate in sysobjects but it's always the same as crdate atleast in my case and i know that alter view/alter table/alter proc commands have been run many times post creation ...

sql server script generater stored proc

anyone know of such stored procs to generate scripts for tables/indexex/views/sp's etc. ...

Odd SQL behavior, I'm wondering why this works the way it does.

Consider the following Transact sql. DECLARE @table TABLE(val VARCHAR(255) NULL) INSERT INTO @table (val) VALUES('a') INSERT INTO @table (val) VALUES('b') INSERT INTO @table (val) VALUES('c') INSERT INTO @table (val) VALUES('d') INSERT INTO @table (val) VALUES(NULL) select val from @table where val not in ('a') I would expect this...

MS SQL share identity seed amongst tables

In MS SQL is it possible to share an identity seed across tables? For example I may have 2 tables: Table: PeopleA id name Table: PeopleB id name I'd like for PeopleA.id and PeopleB.id to always have unique values between themselves. I.e. I want them to share the same Identity seed. Note: I do not want to hear abou...

How do I display/compare a dynamic value of a mysql row in a if statement?

I have a checkboxes on my site that when unchecked, update their row in in the db as unchecked, and if checked,update their row in the db as checked. I am creating an ifstatement that will commence with its command if checked, and not if unchecked. I have echoed the variable and it is holding the proper value (checked or unchecked) but n...

SQL Server Efficiently dropping a group of rows with millions and millions of rows

I recently asked this question: http://stackoverflow.com/questions/2519183/ms-sql-share-identity-seed-amongst-tables (Many people wondered why) I have the following layout of a table: Table: Stars starId bigint categoryId bigint starname varchar(200) But my problem is that I have millions and millions of rows. So when I want to de...

Missing Microsoft.SQLServer dlls

Ok, I installed the Microsoft SQL Server 2005 Backward Compatibility Components here file:///C:/Users/davids/AppData/Local/Temp/instructions_enu.htm but I guess these dlls are not in this. Anyone know where the heck I can get these? Yes, I'm running SQL 2008 so they are missing because they're for 2005. Microsoft.SqlServer.ConnectionI...

Should I include user_id in multiple tables?

I'm at the planning stages of a multi-user application where each user will only have access their own data. There'll be a few tables that relate to each other, so I could use JOINs to ensure they're accessing only their data, but should I include user_id in each table? Would this be faster? It would certainly make some of the queries ea...

MySql - Get row number on select

Can I run a select statement and get the row number if the items are sorted? I have a table like this: mysql> describe orders; +-------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+----...

Notification in case of data changes in SQL and Oracle

I am in the process of building a system where I need to notify a Window Service in a .net based application in case of any change in the DB table (Insert , Update , Delete). I know this can be done with the ADO.NET Events in SQL. Is there any common solution for Oracle and SQL which can provide these kind of notifications. This needs to...