sql-server

Updating a null cell - this stored procedure isn't working - why?

im doing a gym software. i have a signin signout system.when members sign in this data is put in a table leaving the signout colomn empty.then when member sign out the signout cell is updated.up to here is fine. but if the member signed in and out twice i dont want the sigout time of the first time to be changed.i want only the null cell...

Is a trigger what I need?

I am just back in the field after 5 years and am very rustly so please be patient. I am working on sql server express and I need to capture new/updated records(only parts of them actually) from a single table in order to insert into another table. (I will be using this other table as my data source for a crystal report.) I have no test...

SQL Substring using two charindexes problem

I have the following query: DECLARE @str VARCHAR(500) SET @str = 'Barcode: 22037 CaseSize: 1 Qty: 3' SELECT RTRIM(LTRIM( SUBSTRING(@str, CharIndex('CaseSize: ', @str) + 10, CHARINDEX('Qty:', @str)) )) The following results in: '1 Qty: 3' I would like to be able to only select the Case Size number, which is one in t...

What is the default server name in wamp server?

I don't know of the default server name. Can you please help me because I need to work on our project to connect vb.net with wamp server, and for that to happen, I must know the server name that I will put on the codes. Please, thanks in advance. ...

TSQL in SQL 2005: Query

Hi there I have 3 tables: Customer, CustomerTypes, CustomerCustomerTypes. CustomerCustomerTypes is basically is a bridge table between the Customer and CustomerTypes. Table structure: Customers: CustomerID CustomerName CustomerTypes: CustomerTypeID CusctomerTypeName CustomerCustomerTypeID CustomerID CustomerTypeID Sample Data: Custo...

How to import sql in vb.net?

I mean the imports keyword on the uppermost part of the program. What should I type in there? ...

Need help with SQL join to a function

Hello! I am trying to enter the following to an UPDATE trigger of QuoteItem: UPDATE QuoteItem SET List = StyleItem.List, CostFactor = StyleItem.CostFactor, Cost = NULL FROM dbo.fn_GetQuoteItemListPrice(QuoteItem.ItemId, QuoteItem.RoomId) AS StyleItem CROSS JOIN (QuoteItem JOIN INSERTED ON QuoteItem.QuoteItemId = INSERTED.Quot...

How to insert xml into a node in another xml using XQuery?

Hi all, I have two xml variable say @res, @student in a stored proc in SQL server 2005. @res contains <Subject>English</Subject> <Marks>67</Marks> <Subject>Science</Subject> <Marks>75</Marks> @student contains: <Student> <Name>XYZ</Name> <Roll>15</Roll> <Result /> <Attendance>50</Attendance> </Student> I need to in...

select statement for session

Hi,I am new to .net, i write the select statement for session as like Session["RoleId"] = "select roleid from AdminLogin where username='" + txtUserName.Text + "'"; but i m getting error what is problem with this. Thanks in advance... ...

FOR XML EXPLICIT

Hi, Say I have this setup: -- tables declare @main table (id int, name varchar(20)) declare @subA table (id int, mid int, name varchar(20)) declare @subA1 table (id int, subAid int, name varchar(20)) declare @subA2 table (id int, subAid int, name varchar(20)) declare @subB table (id int, mid int, name varchar(20)) -- sample data inser...

Retrieve fields schema in Visual Studio of stored procedure which uses temp tables

I have some complex stored procedures pulling data from other databases using linked servers. This data is put into temp tables which are joined in a select query for output. The procedures work fine but in visual studio if I try to add the stored procedure to a dataset using the designer I get the error invalid object name #tmp or whate...

While loop in Microsoft SQL Server 2008

I'm trying to come up with a simple example of a while loop using Microsoft SQL Server. Here I'm looping through all the tables that begin with the word temp. Declare @Object_ID int,@Name varchar(50) set @Object_ID = 0 while exists ( select * from sys.tables where type = 'u' and object_ID > @Object_ID and Name lik...

SQL error: String or binary data would be truncated

I'm doing an integration on a community platform called Telligent. I'm using a 3rd-party add-on called BlogML to import blog posts from an XML file (in BlogML format) into my local Telligent site. The Telligent platform comes with many classes in their SDK so that I can programmatically add content, such as blog posts. E.g. myWeblogServ...

table transfer from MySQL to MSSQL fails

Hi, I am trying to transfer a table from MySQL to MSSQL using the data migration tool in MS SQL Management studio. I am using .net provider for odbc and selecting the tabel and trying to tansfer. But is is getting the total tables in the database but when I try to transfer it gives error. Even when I try to preview the data, it says, ...

SQL conditional union

Question: I have an SQL function which returns a list of files now I should join an additional list to that list with an union, but only if the user is admin. Is that possible? Something like: CREATE FUNCTION tfu_CMS_Process(@bIsAdmin bit ) -- Add the parameters for the function here RETURNS TABLE AS RETURN ( SELECT * FROM TABLE1 ...

Dynamic forms, Table meta data

I am working with an ASP.Net web app that allows users to create an "application." They define fields and their data types. Based on that, I generate a query to create a table. I would like to use the metadata from the table to generate an input form to display to users. Is this a good approach? Has anybody done a similar proj...

Get maximum value for SQL DateTime in .NET

I could swear there's a property somewhere in SqlClient to do this, but both my Google-fu and IntelliSense have abandoned me. ...

String padding in tsql

I print out a bunch of DDL statements that are dynamically created and want to align the output in a specific way. PRINT 'ALTER TABLE ' + @TableName + ' WITH NOCHECK ADD CONSTRAINT CK_' + @TableName + '_' + @ColumnName + '_MinimumLength CHECK (LEN(' + @ColumnName + ') > 0)' Output: ALTER TABLE SignType ADD CONSTRAINT CK_SignType_Desc...

Select distinct + select top to merge multiple rows

I'm trying to select rows from a table, one row per email address, and return one firstname from the top row in the email list. The query, though, returns multiple email addresses. What am I doing wrong? SELECT DISTINCT email, (SELECT TOP 1 firstname FROM onsite_clients_archive oc WHERE oc.client_id=oca.client_id ...

How do I create a table alias in MySQL

I am migrating an MS Access application (which has linked tables to a MSSQL Server) to MySQL. As a means to overcome some MSAccess table naming problems, I am seeking a solution to add a MySQL table alias that will point to an existing table in the MySQL database. Ideally I would like to create the alias 'dbo_customers' in mysql that ...