Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Monday, March 26, 2012

How do I keep the SQL Statement readable

Is there a way to prevent VS from collapsing the formatting that I do to keep
an SQL statement readable.
I go through all the trouble of writing the statement keeping it nice and
neat, then VS combines it all into one lump of code. This makes editing it
later difficult.Use the generic query window (two pane) instead of the default graphical
query window (4 pane). To switch over to the generic there is a button to
the right of the ...
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"David" <David@.discussions.microsoft.com> wrote in message
news:D4BFC88D-D107-4F49-8125-7F750FC60A4C@.microsoft.com...
> Is there a way to prevent VS from collapsing the formatting that I do to
> keep
> an SQL statement readable.
> I go through all the trouble of writing the statement keeping it nice and
> neat, then VS combines it all into one lump of code. This makes editing it
> later difficult.

Wednesday, March 21, 2012

How do I get the Table Name the column belongs to in SMO?

Hi guys,

I am writing some sort of tool and I need to get the table a column belongs to.Before you ask for certain reasons too long to explain I need to get it from the column.

I have found out that the following will give me the answer however before I start splitting the string which it could be messy.

is there another way to do it?

My way so far:

?col.Urn.Value Gives:
"Server[@.Name='MYServer']/Database[@.Name='MyDB]/Table[@.Name='UserTable' and @.Schema='dbo']/Column[@.Name='Surname']"

So now .How can I split it to get the table Name? or better is there a cleaner way to do it?

Thanks again for your time in advance

col.Parent will return you a SqlSmoObject which you can cast as a Table (or View).

Hope that helps.

Thanks,
Kuntal

|||That helped and worked thanks.

Monday, March 19, 2012

How do i get seq.nextval from within a pl/sql function

Hi,

Im using Oracle 9i and writing a PL/SQL function and i need to get the sequence.nextval within the function. I am getting an error saying sequence does not exist. I have tryed the following :

select mySeq.nextval
into v_myvar
from dual;

but I still get the same error message. Is there any way to get the next value in a sequence from within a PL/SQL function.

Any help would be greatly appreciated.
ThanksCREATE SEQUENCE myseq;

CREATE OR REPLACE FUNCTION fun_seq
RETURN NUMBER
AS
retval NUMBER;
BEGIN
SELECT myseq.NEXTVAL
INTO retval
FROM DUAL;

RETURN (retval);
END;
/

SELECT fun_seq FROM DUAL;

FUN_SEQ
---
1|||Hi,
Thanks. I dont need to create a sequence because the sequence that I am using (mySeq) already exists on the database.

Thanks|||Figured it out. It was a permissions issue.

Monday, March 12, 2012

How do i get Data Type of Each Column in a Sqldatasource control?

Let's say... the sqldatasource has 3 columns: TableKey(int), TableName(string) and StartDate(datetime) and i'm writing a method to return the data type based on the column name.. for example: GetDataType("StartDate") should return "datetime"...what should i do?

I think this is what you need:http://www.java2s.com/Code/VB/Database-ADO.net/GetColunmDatatype.htm

Good luck.

|||

Thanks.