Showing posts with label suppose. Show all posts
Showing posts with label suppose. Show all posts

Wednesday, March 28, 2012

How to change the attribut name?

Hi All,

Suppose I have created one table say "Customer"

Customer (cust_no, cust_name,cust_address)

I want to change the attribute name "cust_no" to "cust_number".

How to do it using ALTER command.

Pls give me the exact syntax for this.

Regards

Abdul

Hi abdul,

The safest way to do so is using the following:

/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
EXECUTE sp_rename N'dbo.Customer.cust_no', N'Tmp_cust_number', 'COLUMN'
GO
EXECUTE sp_rename N'dbo.Customer.Tmp_cust_number', N'cust_number', 'COLUMN'
GO
COMMIT

(An easy way to generate a script like this yourself is changing the layout through SQL Server Management Studio, right-clicking the table, selecting "design", then making the change, and before doing anything else, clicking the left-most button labelled "Generate change script").

HTH.

Peter

Friday, February 24, 2012

How to calculate a date difference in days

Suppose I have these two days fields
ddold 1/1/2005 12:00:00 AM
ddnew 2/1/2007 12:00:00 AM

How can i get the DateDifference of these two dates in days.

Use DateDiff(DateInterval.Day, Fields!Date1.Value, Fields!Date2.Value)

Where date1 is the start date and date2 is end date.

Shyam

|||

Hello Kamii,

If you're wanting to do this from your SQL query...

select datediff(d, ddold, ddnew)

If from Reporting Services, use this as your expression...

=DateDiff("d", Fields!ddold.Value, Fields!ddnew.Value)

Jarret

|||Can u please mark my post as answer?