Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help urgently 1

Status
Not open for further replies.

Vusco

MIS
Apr 15, 2008
3
0
0
ZA
I'm trying to insert data into a table using a select statement as my source,within this select statement I'm retrieving a field that contains a date that is stored as an integer value within,but SQL doesn't like it.

Statement:

EXEC
('INSERT INTO dbo.STG_AML_Customers_list
SELECT
CO_CDE AS CompanyCode,
CUST_FULL_NAME_1 AS CustomerName,
CUST_REC_OPEN_DATE AS CustomerOpenDate,
CUST_TYPE AS CustomerType,
CUST_NO CustomerNumber,
KYC_IND AS KYCIndicator


FROM andwhs01.cpc.dbo.DIM_CUSTOMER_MONTHLY_'+ @Reporting_Month + '
WHERE co_cde = 15
')

Below is the error message it provides:

Server: Msg 260, Level 16, State 1, Procedure SP_aml_Customer_List, Line 26
Disallowed implicit conversion from data type datetime to data type int, table 'CPC.dbo.AML_Customers_list', column 'CustomerOpenDate'. Use the CONVERT function to run this query.
 
Why are you using dynamic SQL?

specify your destination columns INSERT Table (Column1, Column2) SELECT Expression1, Expression2 FROM Table2
 
Can someone provide me with the know how of getting Index selectivity
 
>>Can someone provide me with the know how of getting Index selectivity

something like this

number of unique keys/number of rows
nonclustered indexex with a selectivity less than 0.1 are not efficient and the optimizer will probably not use them

But you have to test this for yourself

Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
SQLBlog.com, Google Interview Questions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top