Showing posts with label functions. Show all posts
Showing posts with label functions. Show all posts

Wednesday, March 21, 2012

Create Script with dependent objects SQL Server 2005

Hi,

I need to script a view but with dependent objects. The view has a lot of user defined functions and manually creating the script is a pain.

There is a way to do it in SQL Server (2000) Enterprise manager where one right clicks the view --> All Tasks --> Generate Script and then Check

"Generate Scripts for all dependent objects" in the Formatting tab.

The db i am using is on SQL Server 2005.

Is there a equivalent way to do this in SQL Server 2005 Management Studio ?

regards,

Rohan Wali

Have you tried the generate script wizard in SSMS?|||You might try using SMO in this case http://www.sqlteam.com/item.asp?ItemID=23185, as I don't see using script wizard.|||

Hi,

Even i dont see a solution using the script wizard. I will try using SMO using the link provided and see how it goes from there.

Thanks for the tip.

regards,

Rohan Wali

sql

Friday, February 17, 2012

Create date Function using SQL

Do anyone know any functions in SQL to create a new date using numeric numbers eg.
day=1, month=2 , year=2003
final = 01/02/2003
please help thanksto_date(lpad(day,2,'0')||'/'||lpad(month,2,'0')||'/'||year,'dd/mm/yyyy')

Originally posted by Twinki
Do anyone know any functions in SQL to create a new date using numeric numbers eg.

day=1, month=2 , year=2003

final = 01/02/2003

please help thanks

Tuesday, February 14, 2012

create custom id's

Hi,
Can someone tell me how to create custom id's in sql server by using
user-defined functions.
I was thinking about creating a id with a length of 6. The first character
should by a alphanumeric.
Then i would like to have some sort of checkid function, if someone insert a
fictious id, it should raise an error.
Is this possible?> I was thinking about creating a id with a length of 6. The first character
> should by a alphanumeric.
ALTER TABLE tbl
ADD id CHAR(6) NOT NULL
CONSTRAINT df_tbl_id DEFAULT ('0'),
CONSTRAINT ck_tbl_id CHECK (id LIKE '[A-Z0-9]%'),
CONSTRAINT pk_tbl PRIMARY KEY (id) ;

> Then i would like to have some sort of checkid function, if someone insert
a
> fictious id, it should raise an error.
ALTER TABLE other_tbl
ADD CONSTRAINT fk_other_tbl_tbl
FOREIGN KEY (id) REFERENCES tbl (id) ;
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--