From: Imre Ament on
Hi,

I have to change all column to unicode in our database.
We use VC++ and OLEDB to access MS SQL Server databases.
In case of varchar, char columns need to remove indexes of the columns
during change its type (to nvarchar, nchar with 'ALTER TABLE table name ALTER
COLUMN columnname nvarchar(...)' command).
There is exist tranact SQL command, stored procedure to get an object create
script (to recreate it)?
I know SQL-DMO and SMO have funtion of it, but can I get object script via
OLEDB?
Thank you for any idea.

Regards,
Imre
From: Uri Dimant on
> I know SQL-DMO and SMO have funtion of it, but can I get object script via
> OLEDB?

You can reference from within VC++ to object library DMO/SMO and script
objects out, there are plenty of example over an internet


"Imre Ament" <ImreAment(a)discussions.microsoft.com> wrote in message
news:407C3878-00D3-4D5A-81C6-1E3EE0FF67DB(a)microsoft.com...
> Hi,
>
> I have to change all column to unicode in our database.
> We use VC++ and OLEDB to access MS SQL Server databases.
> In case of varchar, char columns need to remove indexes of the columns
> during change its type (to nvarchar, nchar with 'ALTER TABLE table name
> ALTER
> COLUMN columnname nvarchar(...)' command).
> There is exist tranact SQL command, stored procedure to get an object
> create
> script (to recreate it)?
> I know SQL-DMO and SMO have funtion of it, but can I get object script via
> OLEDB?
> Thank you for any idea.
>
> Regards,
> Imre


From: Imre Ament on
Yes, I know it, but my question was to it is (script an object) possible with
transact SQL command via OLEDB connection?
In the help I did not found information of it.

Imre

"Uri Dimant" wrote:

> > I know SQL-DMO and SMO have funtion of it, but can I get object script via
> > OLEDB?
>
> You can reference from within VC++ to object library DMO/SMO and script
> objects out, there are plenty of example over an internet
>
>
> "Imre Ament" <ImreAment(a)discussions.microsoft.com> wrote in message
> news:407C3878-00D3-4D5A-81C6-1E3EE0FF67DB(a)microsoft.com...
> > Hi,
> >
> > I have to change all column to unicode in our database.
> > We use VC++ and OLEDB to access MS SQL Server databases.
> > In case of varchar, char columns need to remove indexes of the columns
> > during change its type (to nvarchar, nchar with 'ALTER TABLE table name
> > ALTER
> > COLUMN columnname nvarchar(...)' command).
> > There is exist tranact SQL command, stored procedure to get an object
> > create
> > script (to recreate it)?
> > I know SQL-DMO and SMO have funtion of it, but can I get object script via
> > OLEDB?
> > Thank you for any idea.
> >
> > Regards,
> > Imre
>
>
> .
>
From: Tibor Karaszi on
> Yes, I know it, but my question was to it is (script an object) possible
> with
> transact SQL command via OLEDB connection?

If your question is whether there is functionality to script at the T-SQL
level, then it doesn't matter how you connect (OLEDB, ADO, ADO.NET etc). The
answer is: to some extent:

You can use sp_helptext, OBJECT_DEFINITION(), etc to get the "source code"
for stored procedures, triggers, views and functions.

But not for other object types (tables, indexes etc). For those, the source
code isn't stored. The generate script code that most tools uses lives in
DMO or SMO object layers. Sure, you can write TSQL code to reverse-engineer
the source code from catalog views (just as DMO/SMO does it), but the
question is whether you find it worth the effort... There might be something
in here, but I haven't looked at the subject or updated the page for a while
now: http://www.karaszi.com/SQLServer/info_generate_script.asp.


--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi



"Imre Ament" <ImreAment(a)discussions.microsoft.com> wrote in message
news:ED01A589-396A-4D75-95A5-3CD6B4D6146A(a)microsoft.com...
> Yes, I know it, but my question was to it is (script an object) possible
> with
> transact SQL command via OLEDB connection?
> In the help I did not found information of it.
>
> Imre
>
> "Uri Dimant" wrote:
>
>> > I know SQL-DMO and SMO have funtion of it, but can I get object script
>> > via
>> > OLEDB?
>>
>> You can reference from within VC++ to object library DMO/SMO and script
>> objects out, there are plenty of example over an internet
>>
>>
>> "Imre Ament" <ImreAment(a)discussions.microsoft.com> wrote in message
>> news:407C3878-00D3-4D5A-81C6-1E3EE0FF67DB(a)microsoft.com...
>> > Hi,
>> >
>> > I have to change all column to unicode in our database.
>> > We use VC++ and OLEDB to access MS SQL Server databases.
>> > In case of varchar, char columns need to remove indexes of the columns
>> > during change its type (to nvarchar, nchar with 'ALTER TABLE table name
>> > ALTER
>> > COLUMN columnname nvarchar(...)' command).
>> > There is exist tranact SQL command, stored procedure to get an object
>> > create
>> > script (to recreate it)?
>> > I know SQL-DMO and SMO have funtion of it, but can I get object script
>> > via
>> > OLEDB?
>> > Thank you for any idea.
>> >
>> > Regards,
>> > Imre
>>
>>
>> .
>>