sql

What data can be stored in varbinary data type of sql server?

I have a table in which the userpassword field have varbinary datatype, So im confused that in which form should i save the data into userpassword field because when i save varchar data it gave me error. ...

Recommended approach how to modify schema of a production SQL database?

Say there is a database with 100+ tables and a major feature is added, which requires 20 of existing tables to be modified and 30 more added. The changes were done over a long time (6 months) by multiple developers on the development database. Let's assume the changes do not make any existing production data invalid (e.g. there are defau...

Code to validate SQL Scripts

How i can validate sql scripts before executing using .net2 and c#. If sql is not valid i want to return error rows. ...

Need help with SQL 2000 Stored Procedure

This is my logic. I have an articles table and a matching images tables. The images are stored in binary format. Each image table has 2 instances of each image, this is because I have 2 sizes. 300 x 200 and 500 x 400 with their rows separated by ImageSize I want to write a stored procedure that checks if ImageSize=3 is available and if...

how should I ensure that mytable is efficient

I am desiging a new table that will potentially have 200K rows. I would like to make sure that querys to this table are efficiant. in the past I had always given a row a unique id in the assumption that this would result in an index: CREATE TABLE [dbo].[Equipment]( [EquipID] [nchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, ...

SQL Server 2005: Select statement in ISNULL condition

Environment: SQL Server 2005 I have a stored proc which receives comma separated value in one parameter. I have written a Table Valued UDF function in SQL to break it and and return me it as a table. I am using that value to filter the data in the where clause of the stored proc. Everything works fine until there is NULL in that comma s...

MySQL foreign key question

Does defining a foreign key also defines a index? I have mysql v5.1.46 & I am looking at the MySQL Administrator tool and its shows the foreign key as an index, so I wanted to confirm? ...

Record that is related to all records of other table in SQL

Let's say we have three tables in a relational database: Person {id, name} Obstacle {id, name} Person_overcomes_obstacle {person_id, obstacle_id} I want to write a query that tells me if at least one person has overcome all obstacles. Ideas? ...

SQL Server - lack of NATURAL JOIN / x JOIN y USING(field)

I've just been reading up on NATURAL JOIN / USING - SQL92 features which are (sadly?) missing from SQL Server's current repertoire. Has anyone come from a DBMS that supported these to SQL Server (or another non-supporting DBMS) - were they as useful as they sound, or a can of worms (which also sounds possible!)? ...

How do I Populate a 2-Column table with Unrelated Data from 2 Different Sources?

I have 2 tables, each with an identity column. What I want to do is populate a new 2-column table with those identities so that it results in a pairing of the identities. Now, I am perfectly able to populate one column of my new table with the identities from one of the tables, but can't get the identities from the other table into my n...

How can I convert a OLE Automation Date value to a date in SQL Server

My application stores dates as OLE Automation doubles with the DateTime.ToOADate() command. Now, I need to create a SQL view wich shows me the Date stored. How can I quickly convert the double to a date? Thanks ...

My SQL requires a user has logged in successfully once before, how can I modify to remove that requirement?

Here is my SQL 'SELECT u.`id`, u.`email`, u.`password`, u.`first_name`, u.`last_name`, u.`role_id`, MAX( ul.`datetime` ) as `last_login`, SUM( ul.`failed` ) as `failed_logins` FROM `users` `u` JOIN ( SELECT `user_...

SQL loop problem

Hi guys, I have a problem, I hope somebody out there can help. I'm not really good at sql programming so I need help from u guys. Here's my problem, I have customercode that has possible of 2 or 3 addresses. sample: cust1 address1 cust1 address2 cust1 address3 cust2 address1 cust2 address2 I want to generate a report in .net to...

Add columns to multiple tables in schema

Hi, I need to alter multiple tables in a schema, for all tables prefixed with something, for example: ALTER TABLE "SCHEMA"."TABLE1" ADD ( "COLUMN1" CHARACTER(4) NOT NULL DEFAULT 'DATA', "COLUMN2" VARCHAR(16) NOT NULL DEFAULT 'MORE_DATA', ); I need this to iterate over multiple tables, like SCHEMA.table1, SCHEMA.ta...

SQL Server Stored Procs include file statement

I don't think it is possible to do so what I would but I ask anyway. I've found that I include the same variables in the top of every Stored Proc I make. These variables are used for logging and error handling. They don't change between stored procs, there meaning if fixed but primary use is to help readability and have a consistent sty...

Regarding sql script

I have the line below in a .sql script. Not sure what it does. Does it wait for input from user for dbuserid and password or does it take the values from environment? What does && denote? In test.sql file I saee the line below before creating tables: CONNECT &&usr/&&pass@&&dbname ...

Client Server Application using C# and SQL

Hello Friends, I have developed a desktop application using C# as frontend and SQL as backend. But one of my client wants to buy it if the software is able to operate from multiple computers and a common database must be placed on one main computer (server). Hence I wanted to know, If the already developed application can be configu...

calculating sales, refund and breakages from SQL Server Tables

I have 4 tables namely Products, SalesLog, Breakages, SalesReturn. Products Table CREATE TABLE [dbo].[Products]( [ProductId] [int] IDENTITY(1,1) NOT NULL, [pName] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [pSize] [int] NULL, [pPrice] [decimal](10, 2) NULL, [pPackQty] [int] NULL, [pGroup] [int] NULL, [pCode] [int] NULL, ...

Retreive one row from 1 to many relationship between three tables

I have the following three tables : ----PRODUCT---- PRODUCT_ID DESC 1 'Pencil' 2 'Paper' ----PRICE_BY_SUPPLIER---- PRODUCT_ID SUPPLIER_ID PRICE 1 1 10 1 2 9 1 3 9.5 2 1 5 ...

how to show sales summary in rdlc from four sql table using sql

hello guys, I am having bad times to generate a rdlc report to show report in predefined format given by my client. Client given format As you can notice RED background is my problem area, Item "A" price has been changed thrice. And accordingly their sales, breakages and refund quantity is shown. I have 4 tables Products, SalesLog, Br...