Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 What commands i have to run to get these DDL and D

Author  Topic 

best_boy26
Starting Member

42 Posts

Posted - 2011-03-17 : 14:11:42
I have a view and some table also... When i refer to formus most of them are asking to post the DDL of my tables, also DML to create test data and the query.

What commands i have to run to get these DDL and DML.

Some what urgent this...

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-03-17 : 14:22:49
DDL of Tables means the data definition language of your tables ..e.g.

Create Table TableName (ColumnName1 Datatype,ColumnName2 Datatype, ... , ColumnNameN DataType)

DML Means data manipulation Language, which includes Insert/Delete/Update. e.g. Insert into TableName (ColumnName1,ColumnName2,...,ColumnNameN) Values (Value1,Value2,...,ValueN)

In forums you are asked for this just because that experts would like to have a view of what you have and then to understand your problem/query in light of those information. Hope this clarifies.

Cheers
MIK
Go to Top of Page

best_boy26
Starting Member

42 Posts

Posted - 2011-03-17 : 14:31:50
in my case some one created my tables and views.

How can i get how he/she has created these Views or Tables?
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-17 : 14:33:30
Here's an example

DECLARE @Table Table (Col1 int,Col2 int,Col3 int,Col4 int)
--The above is the DDL,which should have been provided
INSERT INTO @table
SELECT 1,6,8,24
-- this is the sample data, which should have been provided

-- The below is the DML, which I gave as a solution. Even if you DML
-- doesn't work, provide it anyway, as it can give us a better idea
--of what you're trying to accomplish
-- do these things and you'll find you go to the front of line!

Jim

SELECT *
FROM
(

select Col,ColNames,rank() over(order by ColNames desc) as Biggest
from
(select col1,col2,col3,col4
from @table
)pvt
UNPIVOT
(ColNames FOR Col in (Col1,Col2,Col3,Col4)
) as unpvt

) t

WHERE biggest = 1





Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-03-17 : 14:45:18
quote:
Originally posted by best_boy26

in my case some one created my tables and views.

How can i get how he/she has created these Views or Tables?



Right-click the tables/views and choose script to clipboard as create. Then paste it into the forum.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-17 : 14:45:40
Here's the link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

best_boy26
Starting Member

42 Posts

Posted - 2011-03-17 : 14:49:36
Thanks Jimf
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-17 : 15:02:15
You're welcome. And Welcome to SQLTeam!

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -