locked
regarding select into statement RRS feed

  • Question

  • Hi all,

       Please tell me whether i could write a query like this:

    SELECT * INTO [tblTemp] ([rowId] int IDENTITY(1,1),
    [Account Number] varchar(50),
    [Mobile Number] varchar(50) NULL,
    [Name] varchar(100)) NULL'
    FROM OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=file.xls;Extended properties=Excel 8.0')...[Sheet1$]

    shal I define the structure of the table in "select into" query? is it possible? please tell me.

    I thank all in advance
    Friday, September 15, 2006 12:40 PM

All replies

  • The SELECT INTO statement automatically creates a table to receive the data based on the attributes of the columns in the SELECT list. I'm not aware of any way to specify the datatypes, etc using the SELECT INTO statement.

    A couple of options:

    1) Create the table as desired first, then use the INSERT SELECT statement to populate it.

    2) Use the SELECT INTO statement to create the table and then use ALTER TABLE to modify it as needed.

     

    You'll likely get more (and possibly better) responses from another group/forum. This one is dedicated to SQL Server Notification Services. Try microsoft.public.sqlserver.programming newsgroup (http://groups.google.com/group/microsoft.public.sqlserver.programming) or the T-SQL forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=85&SiteID=1).

    HTH...

    Thursday, September 21, 2006 11:22 AM